Re: Getting a foreign key value with @params

Derek DeRaps
Fri, 27 May 2005 16:22:59 -0000

Probably because you are just storing the id through the param hash, not
the actual Item object.

value = Item.find(@params["id"]).name

would probably work as well, though I am not entirely sure.

Good Luck  :)
Derek

s002 wrote:

> For some reason this didn''t work.
>
> value = Item.find(@params["item"]["id"]).name
>
> But this did:
>
> value = Item.find(@params[:id]).name
>
> I don''t know why.  I''m still unclear on some the syntax
issues.
> -Larry
>
> Jarkko Laine wrote:
>
>> On 26.5.2005, at 13:49, s002 wrote:
>>
>>> I''m sure this has a simple solution, but it''s
puzzling to me.
>>>
>>> I have a link that passed the id of a lookup key.   ( item.id) I
>>> want to retrieve the ''name'' column. This is what
I tried.
>>>
>>> @value = subject.@params[:item.id].name
>>>
>>> But it does work.  What am I missing?
>>
>>
>>
>> Let''s assume that what you''re dealing with is an
object of class Item.
>>
>> value = Item.find(@params["item"]["id"]).name
>>
>> //jarkko
>>
>>>
>>> -Larry
>>> _______________________________________________
>>> Rails mailing list
>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>>
>> --
>> Jarkko Laine
>> http://jlaine.net
>> http://odesign.fi
>>
>>
------------------------------------------------------------------------
>>
>> _______________________________________________
>> Rails mailing list
>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>