# Why are parameter values getting lost?

**URL:** <https://www.ruby-forum.com/t/why-are-parameter-values-getting-lost/127391>\
**Category:** Rails\
**Created:** [January 28, 2008, 9:41pm UTC](https://www.ruby-forum.com/t/why-are-parameter-values-getting-lost/127391 "2008-01-28T21:41:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 28, 2008, 9:41pm UTC](https://www.ruby-forum.com/t/why-are-parameter-values-getting-lost/127391/1 "2008-01-28T21:41:46Z")

</div>

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](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](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/](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](http://remandev.no-ip.org/session/create)]  
========================End log  
file=================================================

Why is the parameter value getting lost?

Thanks, - Dave

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 28, 2008, 10:50pm UTC](https://www.ruby-forum.com/t/why-are-parameter-values-getting-lost/127391/2 "2008-01-28T22:50:21Z")

</div>

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
