Simple collection_select problem


#1

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


#2

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.