# Person\["name"\] and person.name

**URL:** <https://www.ruby-forum.com/t/person-name-and-person-name/125654>\
**Category:** Rails\
**Created:** [January 11, 2008, 12:02am UTC](https://www.ruby-forum.com/t/person-name-and-person-name/125654 "2008-01-11T00:02:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/51bf81/32.png) [@OnRails](https://www.ruby-forum.com/u/OnRails)\
**Post date:** [January 11, 2008, 12:02am UTC](https://www.ruby-forum.com/t/person-name-and-person-name/125654/1 "2008-01-11T00:02:18Z")

</div>

I have object person.=\>#\<person id: 123, name: “test”, sex: “1”\>  
when I check name value in rails 2.0.2  
used:  
puts person.name

I got this Error:  
#\<NoMethodError: You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]\>

I use this way in rails 1.2.6, I can get right value “test”

but when I used:  
puts person[“name”]  
I got the value “test”

So Now I have confused, what happen? Who Can tell me why?  
Thanks!

---

<div class="post-metadata">

**Author:** ![OnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/51bf81/32.png) [@OnRails](https://www.ruby-forum.com/u/OnRails)\
**Post date:** [January 11, 2008, 12:57am UTC](https://www.ruby-forum.com/t/person-name-and-person-name/125654/2 "2008-01-11T00:57:57Z")

</div>

Hi, could you provide a little bit more detail? I’m guessing that  
you’re  
entering that data into a form. Thus, could you provide the form as  
well as  
the processing code? Next, person.name from the context of the Ruby  
code  
should be an instance of Person.rb. Lastly, if the post variable in  
your  
form is name=“person[name]”, then you can access in the resulting action  
as  
follows:

def \<my\_action\_method\>

name = params[:person][:name]

end

Good luck,

-Conrad
