public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# config/environments/development.rb
 
Hello::Application.configure do
# ...
 
# https://rails.lighthouseapp.com/projects/8994/tickets/4676-reload-routes-on-each-request-in-dev-mode
service_reloader = ActiveSupport::FileUpdateChecker.new(Dir["app/services/**"]) { Rails.application.reload_routes! }
 
config.to_prepare do
service_reloader.execute_if_updated
end
end
 
# app/services/main_service.rb
 
require 'sinatra/base'
require 'sinatra/reloader'
 
class MainService < Sinatra::Base
configure :development do
register Sinatra::Reloader
end
 
get "/" do
"hi everybody!"
end
end
 
# config/routes.rb
 
Hello::Application.routes.draw do
mount MainService, at: "/api"
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.