[Rails] Re: Use find with a variable
So, I do find the "part", using a = Part.find_by_id(the_id)
If I do <%= debug a %> I get...
----------------------
attributes:
name: Western Digital - Caviar GP 500GB Internal Hard Drive
created_at: 2011-08-23 18:54:12.214873
cost: 49.99
updated_at: 2011-08-23 18:54:12.214873
id: 2
[...]
-------------------
but if I do
a.cost
I get error...
undefined method `cost' for nil:NilClass
How is it going to be a nil class? If I do a.class I get "Part", then
it's NOT a nil class.
It's weird, if I do exactly the same thing in the console a.cost does
work.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home