Dear all,
[Apologies for a rather newbie question]. I have been seeing some rather weird behaviour with my Rails setup (2.3.5) since yesterday. I installed AuthLogic for authentication, and tested a basic login page with it on my development machine; it ran fine. On my production Linux server, though, submitting the login form doesn’t work right - Rails sees the POST request as a GET request and so tries to display the wrong page.
The sessions are handled in the user_sessions class, with the following added to the routing:
map.login “login”, :controller => “user_sessions”, :action => “new”
map.logout “logout”, :controller => “user_sessions”, :action => “destroy”
map.resources :user_sessions
The relevant sections in the user_sessions_controller are:
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
uri = session[:original_uri] #This was set in the authorize method that's called using a :before_filter
session[:original_uri] = nil
redirect_to(uri || root_url)
else
flash[:error] = "Incorrect Email/Password!"
render :action => :new
end
end
The user_sessions/new form is:
<% form_for @user_session do |f| %>
<%= flash[:error] %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.submit “Login” %>
<% end %>
The rendered form in HTML starts with:
… which is as expected, with the method set to POST.
And all this works fine on the development machine. I get this in the log:
Processing UserSessionsController#create (for 127.0.0.1 at 2010-10-08 19:05:20) [POST]
Parameters: {“commit”=>“Login”, “user_session”=>{ “password”=>“precisely”, “email”=>“test@test.com”}, “authenticity_token”=>“x1agQNW4O3qtP7L3ifif6Ih4/jP/pWDP73QM4DD7gS4=”}
On production, though, submitting the email/password shows this in the log file:
Processing UserSessionsController#index (for 122.179.58.136 at 2010-10-08 18:37:04) [GET]
ActionController::UnknownAction (No action responded to index. Actions: available_languages, convert_date, create, current_language, destroy, and new):
/opt/passenger-2.2.15/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request’
/opt/passenger-2.2.15/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop’
/opt/passenger-2.2.15/lib/phusion_passenger/rack/application_spawner.rb:120:in `run’
/opt/passenger-2.2.15/lib/phusion_passenger/rack/application_spawner.rb:65:in `spawn_application’
/opt/passenger-2.2.15/lib/phusion_passenger/utils.rb:252:in `safe_fork’
/opt/passenger-2.2.15/lib/phusion_passenger/rack/application_spawner.rb:58:in `spawn_application’
/opt/passenger-2.2.15/lib/phusion_passenger/rack/application_spawner.rb:41:in `spawn_application’
/opt/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:150:in `spawn_application’
/opt/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application’
/opt/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `send’
/opt/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop’
/opt/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously’
Rendering /www/apps/releases/20101008104549/public/404.html (404 Not Found)
Note the [GET] - I see a POST in the same position on my development machine, and it calls the create action as expected. No matter what I do, I can’t get the form on the production server to return a POST request. Has anyone any insights into this? Any help will be much appreciated.
Thanks,
Sudarshan