Why are parameter values getting lost?

Hi,

I have this login form (app/views/register/start.rhtml):

<% form_tag ‘session/new’ do -%>

Login
<%= text_field_tag 'login' %>

Password
<%= password_field_tag 'password' %>

<%= submit_tag 'Log in' %>

<% end -%>

But it seems when my form is getting processed by my app/controllers/
session_controller.rb controller, the value of the login parameter is
NULL. Here’s the controller code and the entry from the log file:

===============controller code================================
def create
self.current_user = User.authenticate(params[:login],
params[:password])
if logged_in?
if params[:remember_me] == “1”
self.current_user.remember_me
cookies[:auth_token] = { :value =>
self.current_user.remember_token , :expires =>
self.current_user.remember_token_expires_at }
end
# The next two lines were added 1/24/08
@user = User.find(:first, :conditions => [“login = ?”,
params[:login]])
session[:user_id] = @user.id
flash[:notice] = “Logged in successfully”
redirect_to :controller => ‘order’, :action => ‘start’
else
flash[:error] = “Authentication failed.”
redirect_to :controller => ‘register’, :action => ‘start’
end
end
================end controller code============================

===============Log file entry begin =============================
Processing SessionController#new (for 67.190.94.163 at 2008-01-28
11:00:03) [POST]
Session ID: ed02a351a99f5581a92ac20208cad3b7
Parameters: {“commit”=>“Log in”, “action”=>“new”,
“controller”=>“session”, “login”=>“abc”, “password”=>“abc”}
Redirected to http://remandev.no-ip.org:3000/session/create
Completed in 0.00217 (461 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://remandev.no-ip.org/session/new]

Processing SessionController#create (for 67.190.94.163 at 2008-01-28
11:00:04) [GET]
Session ID: ed02a351a99f5581a92ac20208cad3b7
Parameters: {“action”=>“create”, “controller”=>“session”}
^[[4;36;1mUser Columns (0.005551)^[[0m ^[[0;1mSHOW FIELDS FROM
users^[[0m
^[[4;35;1mUser Load (0.003246)^[[0m ^[[0mSELECT * FROM users WHERE
(users.login IS NULL) LIMIT 1^[[0m
Redirected to http://remandev.no-ip.org:3000/
Completed in 0.02045 (48 reqs/sec) | DB: 0.00880 (43%) | 302 Found
[http://remandev.no-ip.org/session/create]
========================End log
file=================================================

Why is the parameter value getting lost?

Thanks, - Dave

i’m pretty sure it’s to do with the bit when you redirect to ‘create’

i’m not sure why you’re doing it like that but to keep hold of the
params i think you need to put them in local(?) variables…when you
receive them in new you need to say, for example, @login =
params[:login], @password = params[:password], then I THINK you’ll be
able to see these variables in your create action

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs