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.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris (Guest)
on 2006-04-25 11: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
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2006-04-25 11: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.