Forum: Ruby on Rails simple collection_select problem.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris (Guest)
on 2006-04-25 13:02
Hi,

I can do this :

collection_select "state", :id, TrainingState.find_all,:id,:name

but not this :

collection_select "state[]", :id, TrainingState.find_all,:id,:name

Anyone any idea why?  Is there something about collection_select that
does not allow collections?

Thanks
Chris
Mark Reginald J. (Guest)
on 2006-04-25 13:49
(Received via mailing list)
Chris wrote:

> I can do this :
>
> collection_select "state", :id, TrainingState.find_all,:id,:name
>
> but not this :
>
> collection_select "state[]", :id, TrainingState.find_all,:id,:name

This will work, but only when @state came from the DB, not
when it's new.  When new you need to use the index option
instead.

Plus I don't think you want to use a dropdown to select the
id attribute of @state.  Shouldn't it be something like
training_state_id instead?

--
We develop, watch us RoR, in numbers too big to ignore.
This topic is locked and can not be replied to.