Rails - 401 Unauthorized access to action only in Production

I am using Ruby On Rails 3.0.9 and everything works fine on Development env. When I switch to Production env or upload it to our server, after logging in, I return to the same login page. When I check the log, I see the following:

Started POST "/users/login" for 127.0.0.1 at Thu Oct 03 16:48:13 -0300 2013
  Processing by UserSessionsController#create as HTML
  Parameters: {"user"=>{"password"=>"[FILTERED]", "login"=>"demo_admin"}, "utf8"=>"✓", "authenticity_token"=>"+7AEoVXZ9XiagEymVUnOhFHnck4rgDu883E/ySMlCxQ="}
Redirected to http://localhost:3000/admin
Completed 302 Found in 111ms


Started GET "/admin" for 127.0.0.1 at Thu Oct 03 16:48:13 -0300 2013
  Processing by Admin::DashboardController#index as HTML
Completed 401 Unauthorized in 1ms

I use the authorization_rules file for access control, but I have no problem with Dev env, as I said.

If I set a breakpoint in action admin/dashboard#index, it will not be executed, as it will not be reached. It breaks into an httpserver file (I debugged it step by step), but I can’t understand why it works on Dev and not on Prod env.

Please, help.

Thanks Brian

UPDATE

, ApplicationController before_filter, check_plan_features, , , unless current_user.blank? #redirects to Admin section.

, , Devise, current_user , admin , current_user null, , , - . , , , .

+4
1

( 4 3).

config/initializers/session_store.rb :

YourAppName::Application.config.session_store :cookie_store, key: '_your_session', domain: {
  production: 'production_domain',
  development: 'development_domain'
}.fetch(Rails.env.to_sym, :all)

, - .

+1

All Articles