# How do I access this parameter?

**URL:** <https://www.ruby-forum.com/t/how-do-i-access-this-parameter/129130>\
**Category:** Rails\
**Created:** [February 14, 2008, 6:20pm UTC](https://www.ruby-forum.com/t/how-do-i-access-this-parameter/129130 "2008-02-14T18:20:42Z")\
**Posts on this page:** 5\
**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:** [February 14, 2008, 6:20pm UTC](https://www.ruby-forum.com/t/how-do-i-access-this-parameter/129130/1 "2008-02-14T18:20:42Z")

</div>

Hi,

I have a form for creating users …

\<% form\_tag ‘userconfirm’ do -%\>

Username  
\<%= text\_field 'user', 'login' %\>

Password  
\<%= password\_field 'user', 'password' %\>

Confirm Password  
\<%= password\_field 'user', 'password\_confirmation' %\>

\<% end -%\>

My question is, on the controller end, how do I access the parameter  
for login and password? I thought it would be params[:login] and  
params[:password], but that is not right. Any help is appreciated, -  
Dave

My code now:

```
    def userconfirm
            @user = User.new(params[:user])
            if @user.save
                    # Create session
                    if (log_user_in(params[:login],

```

params[:password], nil))  
redirect\_to :controller =\>  
‘order’, :action =\> ‘new’  
else  
flash[:notice] = “You are not logged  
in.”  
redirect\_to :action =\> “start”  
end  
else  
render :action =\> ‘userinfo’  
end  
end

---

<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:** [February 14, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/how-do-i-access-this-parameter/129130/2 "2008-02-14T18:36:36Z")

</div>

On 14 Feb 2008, at 17:19, removed\_email\_address@domain.invalid wrote:

> Password  
> \<%= password\_field 'user', 'password' %\>
> 
> Confirm Password  
> \<%= password\_field 'user', 'password\_confirmation' %\>
> 
> \<% end -%\>

Just take a look in your log files and you’ll see that they arrive as  
params[:user][:login], params[:user][:password]

Fred

---

<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:** [February 14, 2008, 7:10pm UTC](https://www.ruby-forum.com/t/how-do-i-access-this-parameter/129130/3 "2008-02-14T19:10:51Z")

</div>

Add the following if you are unsure in the controller method of  
interest:

puts params.inspect

it will dump the values to the console as another option to check…

---

<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:** [February 14, 2008, 8:11pm UTC](https://www.ruby-forum.com/t/how-do-i-access-this-parameter/129130/4 "2008-02-14T20:11:08Z")

</div>

Thanks for your help. It was indeed params[:user][:login]. I didn’t  
know I could use the log file so I’m grateful also for that info, -  
Dave

On Feb 14, 11:35 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<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:** [February 14, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/how-do-i-access-this-parameter/129130/5 "2008-02-14T20:15:14Z")

</div>

If you are using rails 2, you can also use the debugger which is a TON  
of  
help. start script/server with --debugger and put “debugger” on the  
line  
you want it to stop on. Then you can inspect variables, step, and even  
evaluate routines. WAY cool!!

–Alan

On Thu, Feb 14, 2008 at 1:10 PM, removed\_email\_address@domain.invalid \<
