I’m rendering my form in a partial, as below:
…
<%= f.collection_select :color_id, @colors, :id, :name, {:include_blank
=> false, :prompt => ‘What color?’} %>
…
Now, I’m rendering this partial in both the new and edit methods of my
controller. Everything works great, except for one caveat.
If the user deletes the color that was assigned prior, this results in
the parent object being assigned a color ID that doesn’t exist.
It doesn’t throw up any errors, but when you go into the edit method of
the parent controller to change the color, another color is
automatically selected. It seems that the options for :prompt are
ignored when the value is passed when in the edit method for example,
even if that value no longer exists.
What I’d like for it to do is to show the prompt - even in the edit
method - if the value doesn’t exist. Any way to do this?
Thanks in advance for any help at all.