Skip to content

Commit

Permalink
Fixes a bug where custom exceptions app does not load on Rails 6
Browse files Browse the repository at this point in the history
closes #52
  • Loading branch information
yuki24 committed Oct 1, 2019
1 parent 20a7d2a commit d5a683b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lib/rambulance/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,27 @@ class Railtie < Rails::Railtie
require "rambulance/exceptions_app"
end

app.config.exceptions_app = ->(env) {
begin
ActiveSupport::Dependencies.load_missing_constant(Object, :ExceptionsApp)
::ExceptionsApp.call(env)
rescue NameError
require "rambulance/exceptions_app" if !defined?(::Rambulance::ExceptionsApp)
::Rambulance::ExceptionsApp.call(env)
app.config.exceptions_app =
if app.config.respond_to?(:autoloader) && app.config.autoloader == :classic
->(env) {
begin
ActiveSupport::Dependencies.load_missing_constant(Object, :ExceptionsApp)
::ExceptionsApp.call(env)
rescue NameError
require "rambulance/exceptions_app" if !defined?(::Rambulance::ExceptionsApp)
::Rambulance::ExceptionsApp.call(env)
end
}
else
->(env) {
begin
::ExceptionsApp.call(env)
rescue NameError
require "rambulance/exceptions_app" if !defined?(::Rambulance::ExceptionsApp)
::Rambulance::ExceptionsApp.call(env)
end
}
end
}

ActiveSupport.on_load(:after_initialize) do
Rails.application.routes.append do
Expand Down

0 comments on commit d5a683b

Please sign in to comment.