Fernando,
On 14.4.2005, at 09:13, Fernando Blat Peris wrote:
> On Wed, Apr 13, 2005 at 03:04:38PM -0400, Dev Purkayastha wrote:
>>> And when I create a new article I have this code:
>>>
>>> <select multiple name="@article.categories[id]"
size="7">
What do you think giving a select tag a name like that gives you? You
have a reference to a ruby instance variable in html code where it
won''t get parsed. So changing it to something reasonable (like
"category[]") should help you. You''d then have an array of
selected
values in @params["category"]. Note that you need the empty brackets
after the name so that rails knows it''s a multiselect field and puts
the values in an array.
//jarkko
>>> <%= options_from_collection_for_select @categories,
"id",
>>> "name", @article.categories.collect { |c| c.categorie_id
} %>
>>> </select>
>>>
>>> which I think it''s wrong.
>>
>> To be clear, what do you think is wrong about it?
>
> Because it doesn''t work: after creating a new article and
assigning it
> two categories, I try to print the categories of this article and it
> hasn''t
> any category assigned.
>
>> _______________________________________________
>> Rails mailing list
>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
>
> --
> Fernando Blat Peris
> <ferblape-I8oKXW6Z+bze5aOfsHch1g@public.gmane.org>
> _______________________________________________
> 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