Skip to content

Commit

Permalink
Hookpoint for middleware checking is inadequate, causing succeeding i…
Browse files Browse the repository at this point in the history
…nitializers to be executed after build_middleware_stack

Fixes #3060
  • Loading branch information
mshibuya committed Sep 23, 2018
1 parent 6d08234 commit 94928d1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rails_admin/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class Engine < Rails::Engine
Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
end

initializer 'RailsAdmin check for required middlewares', after: :build_middleware_stack do |app|
# Check for required middlewares, can be missing in Rails API mode
config.after_initialize do |app|
has_session_store = app.config.middleware.to_a.any? { |m| m.klass.try(:<=, ActionDispatch::Session::AbstractStore) } || ::Rails.version < '5.0'
loaded = app.config.middleware.to_a.map(&:name)
required = %w(ActionDispatch::Cookies ActionDispatch::Flash Rack::MethodOverride)
Expand Down

0 comments on commit 94928d1

Please sign in to comment.