开发者

Rails 3 subdomain

I would like to publish my application to a selected set of individuals for a private beta. I created a sub-domain for this task: beta.company.com.

The application operates as expected on my workstation, but when I push it to the server, the application continually routes back to the authentication page. FYI, I'm using declarative-authorization, authlogic, and Passenger.

routes.rb:

  #Application controller
  match "/not_authorized", :to => "application#not_authorized", :as => :not_authorized

  #UserSessions controller
  match "/quit", :to => "user_sessions#des开发者_StackOverflow中文版troy", :as => :quit
  match "/authenticate", :to => "user_sessions#new", :as => :authenticate
  resources :user_sessions, :only => :create

  #Users controller
  match "/enroll", :to => "users#new", :as => :enroll

  # root url
  root :to => "users#index"

Symptoms:

  • anonymous routes (e.g. user_sessions#create, not_authorized) work as expected for anon. user
  • the application operates as expected on my workstation

When I look at the production.log, I see an entry like:

Processing by UsersController#index as HTML Permission denied: No matching rules found for index for # @role_symbols=[:guest]> (roles [:guest], privileges [:index, :read, :manage], context :users). Redirected to http://beta.company.com/authenticate

** edit **

For one, there isn't a UsersController#index action, and if there was, the anonymous user wouldn't have access to it. I'm confused to why it is trying to route there at all (instead of the root url, which is where it should go after a successful authentication).

This seems like a sub-domain-specific routing issue, but I can't be sure.

re-read this 'error' more closely. there is a UserController#index action AND the anonymous user should NOT have access to it. at first glance, i thought it read UserSessionController#index, which is the action that doesn't exist.

now, it seems like the authenticated user isn't being created or saved and consequently, is being re-routed back to UserSession#new action (AKA authenticate path).

** / edit **

** edit II **

I changed from cookie_store to active_record_store:

# cookie store
# MyApp::Application.config.session_store :cookie_store, :key => '_myApp_session'
# active-record store
MyApp::Application.config.session_store :active_record_store

Added the table ($ rake db:sessions:create), did the migration ($ rake db:migrate), restarted Apache ($ touch tmp/restart.txt), cleared the browser's cache, then restarted the browser.

The session was added to the sessions table successfully, but I still get the problem.

** / edit II **

Thoughts are greatly appreciated.


For starters…

For one, there isn't a UsersController#index action, and if there was, the anonymous user wouldn't have access to it. I'm confused to why it is trying to route there at all (instead of the root url, which is where it should go after a successful authentication).

Your root URL is UsersController#index:

# root url
root :to => "users#index"

Check to make sure you are setting the cookie on the beta domain. You might be redirecting or setting links that use the full URL (rather than just the path, so user_url(@user) vs user_path(@user)), which would cause you to be headed straight for the root domain.


The issue was related to a SELECT statement in the controller. The case-sensitivity of the table name in the SELECT statement, "SELECT Users.*", was causing an error. For some reason, this error was not being included in the production.log file. A subsequent deployment, not using Capistrano, did something (I still don't know what) to enable this error to be included in the production.log file.

Now, if I could just determine what that 'something' was...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜