Person["name"] and

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

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?

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

def <my_action_method>

name = params[:person][:name]


Good luck,


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