Unable to read values from object returned from ActiveRecord.find
Posted
by Venki
on Stack Overflow
See other posts from Stack Overflow
or by Venki
Published on 2010-03-27T17:13:20Z
Indexed on
2010/03/27
17:23 UTC
Read the original article
Hit count: 219
ruby-on-rails
I make the following call to the DB.
@patientRegistration = PatientRegistration.find(:all, :conditions=>["name = '#{patientName}'"])
Search for patient registration based on a given name. I get a valid @patientRegistration object.When I invoke @patientRegistration.inspect it prints correctly all the values for the object in the DB.
But when I try to read a particular attribute (Say id or name) by doing the following: @patientRegistration.id or @patientRegistration.name. I get invalid values. Either its blank or some junk values. I dont understand how inspect is able to retrieve all the values correctly but reading individual attributes gives invalid values.
Thanks
© Stack Overflow or respective owner