When I'm in the Rails 3.2 console, I can do it just fine:
p = Person.last
p.last_name
and he prints the last name.
But when I try to find it using id, it can find a single record and save it in my variable p, but I can not print the last_name
column. For instance:
p = Person.where(id: 34).limit(1)
the print phere shows all the columns but p.last_namesays so
NoMethodError: undefined method `last_name' for
#<ActiveRecord::Relation:0x000000055f8840>
Any help would be appreciated.
source
share