Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needed middlewares check broken app using redis session store #3076

Closed
PikachuEXE opened this issue Oct 9, 2018 · 13 comments
Closed

Needed middlewares check broken app using redis session store #3076

PikachuEXE opened this issue Oct 9, 2018 · 13 comments

Comments

@PikachuEXE
Copy link
Contributor

Just updated to rails_admin 1.4.2 and got this error on start up:

Required middlewares for RailsAdmin are not added
To fix tihs, add

  config.middleware.use ActionDispatch::Session::RedisStore, {:redis_server=>{:host=>"127.0.0.1", :port=>6379, :password=>nil, :namespace=>"spacious:development:sessions"}, :key=>"_spacious_development_sessions_v2017_01_04_1426"}

to config/application.rb.

instruction is followed, but error still appears

error raised from
https://github.com/sferik/rails_admin/blob/v1.4.2/lib/rails_admin/engine.rb#L46

related issue raised in redis-actionpack

@PikachuEXE
Copy link
Contributor Author

Anyone?

@mshibuya
Copy link
Member

Just pushed the fix, please let me know if it works.

@PikachuEXE
Copy link
Contributor Author

@mshibuya I confirm the fix is working for my app. Thanks!

@kaleemullah360
Copy link

I am also experiencing same issue with Rails 6.0.0.rc1 and Rails_Admin 2.0.0.beta.

/var/lib/gems/2.5.0/gems/rails_admin-2.0.0.beta/lib/rails_admin/engine.rb:57:in `block in <class:Engine>': Required middlewares for RailsAdmin are not added (RuntimeError)
To fix this, add

  config.middleware.use ActionDispatch::Cookies
  config.middleware.use ActionDispatch::Flash
  config.middleware.use Rack::MethodOverride
  config.middleware.use ActionDispatch::Session::CookieStore, {:key=>"_pro_dejurebe_session"}

to config/application.rb.

@kaleemullah360
Copy link

adding following lines didn't resolved the issue.

  config.middleware.use ActionDispatch::Cookies
  config.middleware.use ActionDispatch::Flash
  config.middleware.use Rack::MethodOverride
  config.middleware.use ActionDispatch::Session::CookieStore, {:key=>"_pro_dejurebe_session"}

to config/application.rb

@mshibuya
Copy link
Member

Can I take a look at your config/application.rb?

@kaleemullah360
Copy link

sorry for delay in reply, here is my application.rb file.

require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
require "sprockets/railtie"
require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module ProDejurebe
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 6.0

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.

    # Only loads a smaller set of middleware suitable for API only apps.
    # Middleware like session, flash, cookies can be added back manually.
    # Skip views, helpers and assets when generating a new resource.
    config.api_only = true
    config.middleware.use ActionDispatch::Cookies
    config.middleware.use ActionDispatch::Flash
    config.middleware.use Rack::MethodOverride
    config.middleware.use ActionDispatch::Session::CookieStore, {:key=>"_pro_dejurebe_session"}
  end
end

@okuramasafumi
Copy link
Contributor

Is this fixed with version 2.0?

@mshibuya
Copy link
Member

Of course, still having this?

@okuramasafumi
Copy link
Contributor

#3076 (comment)
It wasn't clear if this was resolved or not.
If Rails 6 and rails_admin 2 works well together, it's great!

@mshibuya
Copy link
Member

Ah sorry I overlooked @kaleemullah360 's case 😨
I cloud not find anything suspicious in your code, can you paste full stack trace of the error?

@richardkmichael
Copy link

richardkmichael commented Feb 10, 2020

Update: I tested with tip of branch 1.x-stable (currently at 7528459) and it is fixed. Perhaps you can release 1.4.3 if is ready.

This seems to still be a problem.

Rails 5.2.4.1, rails_admin 1.4.2.

Stacktrace when trying to run bin/rails:

Traceback (most recent call last):
        59: from bin/rails:3:in `<main>'
        58: from bin/rails:3:in `load'
        57: from /Users/testuser/test/app/bin/spring:15:in `<top (required)>'
        56: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        55: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        54: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
        53: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
        52: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
        51: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
        50: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
        49: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
        48: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
        47: from /Users/testuser/test/app/bin/rails:9:in `<top (required)>'
        46: from /Users/testuser/test/app/bin/rails:9:in `require'
        45: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands.rb:18:in `<top (required)>'
        44: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:46:in `invoke'
        43: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command/base.rb:69:in `perform'
        42: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
        41: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
        40: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
        39: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/help/help_command.rb:11:in `help'
        38: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:86:in `print_commands'
        37: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:93:in `sorted_groups'
        36: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:93:in `transform_values!'
        35: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:93:in `block in sorted_groups'
        34: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:93:in `flat_map'
        33: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:93:in `each'
        32: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:12:in `printing_commands'
        31: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:42:in `formatted_rake_tasks'
        30: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:33:in `rake_tasks'
        29: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
        28: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command/actions.rb:28:in `require_environment!'
        27: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/application.rb:337:in `require_environment!'
        26: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
        25: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
        24: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
        23: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
        22: from /Users/testuser/test/app/config/environment.rb:5:in `<top (required)>'
        21: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/application.rb:361:in `initialize!'
        20: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:60:in `run_initializers'
        19: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
        18: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
        17: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
        16: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `call'
        15: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each'
        14: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
        13: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
        12: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        11: from /Users/rmichael/.rbenv/versions/2.6.5/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
        10: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
         9: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `run'
         8: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `instance_exec'
         7: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
         6: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
         5: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
         4: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
         3: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
         2: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
         1: from /Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/Users/testuser/test/app/vendor/bundle/ruby/2.6.0/gems/rails_admin-1.4.2/lib/rails_admin/engine.rb:55:in `block in <class:Engine>': Required middlewares for RailsAdmin are not added (RuntimeError)
To fix tihs, add

  config.middleware.use ActionDispatch::Session::CookieStore, {:key=>"_test_app_session", :cookie_only=>true}

to config/application.rb.

@Uepsilon
Copy link

☝️ can confirm that it's still an issue with rails 5.2.4.1 and rails_admin 1.4.2 but 1.x-stable fixes it just fine. Please release a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants