Re: [Rails] Re: get property of a model data
On 10 September 2012 03:58, Soichi Ishida <lists@ruby-forum.com> wrote:
>> item = @result.first
>> item.user_id
>>
>
>
> It worked fine! Thank you very much.
> Now I need to study 'type Relation' :)
The reason it did not work originally is that @result is not a single
record, it is all the records that match the where clause. In
practice it may be only one but it will still be returned in,
effectively, an array. Hence the need to use .first to get the first
one.
Colin
--
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 https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home