Why are parameter values getting lost?


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

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

<%= text_field_tag 'login' %>

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

===============Log file entry begin =============================
Processing SessionController#new (for 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

Processing SessionController#create (for 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
^[[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
========================End log

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