# Beginner Questions parameter passing failing

**URL:** <https://www.ruby-forum.com/t/beginner-questions-parameter-passing-failing/51822>\
**Category:** Rails\
**Created:** [January 7, 2006, 6:09pm UTC](https://www.ruby-forum.com/t/beginner-questions-parameter-passing-failing/51822 "2006-01-07T18:09:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Baldwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ec9cab/32.png) [@Peter\_Baldwin](https://www.ruby-forum.com/u/Peter_Baldwin)\
**Post date:** [January 7, 2006, 6:09pm UTC](https://www.ruby-forum.com/t/beginner-questions-parameter-passing-failing/51822/1 "2006-01-07T18:09:24Z")

</div>

Dear all,

I’m pretty much a complete programming novice, but I’ve battled my way  
through

the Pickaxe book, and the Agile Rails book, and am trying to piece  
together

some pretty basic functionality at the moment.

I’m having an issue passing parameters from a login form and would  
really

appreciate some assistance. I suspect I’ve made some basic fundamental  
error,

but I can’t figure it out.

My “welcome” view page looks like this (my “welcome” action doesn’t do  
anything

but render the welcome view)

```
   <%= start_form_tag :action => :login %>

   <table>

        <tr>

                    <td> Enter your first name </td>

                    <td> <%= text_field :user, :firstname, 'size' => 

```

40  
%\>

```
        <tr>

                    <td> </br> <%= submit_tag("Log In") %></td>

    <%= end_form_tag %>

    </table>

```

Which simply submits a firstname to my login action which tries to match  
it  
up

to an entry in my User model (which has firstname, lastname, email,  
password  
fields)

```
 def login

         @user = User.find_by_firstname(params[:firstname])

 end

```

However, when I try and display the resulting @user.firstname in the  
login  
view

I always get the following error.

NoMethodError in Useradmin#login

Showing app/views/useradmin/login.rhtml where line #4 raised:

You have a nil object when you didn’t expect it!

The error occured while evaluating nil.firstname

This error appears even though the name submitted in the form matches  
one in  
the

database. The action works if I hard code the name instead of the

“params[:firstname]” text, so I think it’s an issue with the parameters  
passing.

Any assistance gratefully recieved.

Pete

* * *

Outgoing mail is certified Virus Free.  
Checked by AVG anti-virus system ([http://www.grisoft.com](http://www.grisoft.com)).  
Version: 6.0.764 / Virus Database: 511 - Release Date: 15/09/2004

---

<div class="post-metadata">

**Author:** ![Peter\_Baldwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ec9cab/32.png) [@Peter\_Baldwin](https://www.ruby-forum.com/u/Peter_Baldwin)\
**Post date:** [January 7, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/beginner-questions-parameter-passing-failing/51822/2 "2006-01-07T18:14:03Z")

</div>

Hi Peter,

Use @user = User.find\_by\_firstname(params[:user][:firstname])

Your forgot the [:user] bit.

Joerg

---

<div class="post-metadata">

**Author:** ![Peter\_Baldwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ec9cab/32.png) [@Peter\_Baldwin](https://www.ruby-forum.com/u/Peter_Baldwin)\
**Post date:** [January 7, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/beginner-questions-parameter-passing-failing/51822/3 "2006-01-07T18:14:10Z")

</div>

Hi Peter,

Use @user = User.find\_by\_firstname(params[:user][:firstname])

You forgot the [:user] bit.

Joerg

---

<div class="post-metadata">

**Author:** ![Peter\_Baldwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ec9cab/32.png) [@Peter\_Baldwin](https://www.ruby-forum.com/u/Peter_Baldwin)\
**Post date:** [January 7, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/beginner-questions-parameter-passing-failing/51822/4 "2006-01-07T18:35:02Z")

</div>

Thanks for that really quick response. Much appreciated.

Pete
