Leonel *.* wrote in post #1018495:
> 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.

Do you get an error if you do this:

<%
part = Part.find_by_id(the_id)
part.cost
%>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to