Skip to content

Commit

Permalink
Session stores are not always subclasses of ActionDispatch::Session::…
Browse files Browse the repository at this point in the history
…AbstractStore

Fixes #3076, refs. redis-store/redis-actionpack#22
  • Loading branch information
mshibuya committed Oct 15, 2018
1 parent c427553 commit e68c75c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rails_admin/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ class Engine < Rails::Engine
Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
end

# Check for required middlewares, can be missing in Rails API mode
# Check for required middlewares, users may forget to use them 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'
has_session_store = ::Rails.version < '5.0' || app.config.middleware.to_a.any? do |m|
m.klass.try(:<=, ActionDispatch::Session::AbstractStore) ||
m.klass.name =~ /^ActionDispatch::Session::/
end
loaded = app.config.middleware.to_a.map(&:name)
required = %w(ActionDispatch::Cookies ActionDispatch::Flash Rack::MethodOverride)
missing = required - loaded
Expand Down

0 comments on commit e68c75c

Please sign in to comment.