Ruby Forum Ruby on Rails > select tag and fieldWithErrors

Posted by flukus@gmail.com (Guest)
on 05.03.2007 09:57
(Received via mailing list)
I've been trying to work out the rails way of handling this. I have my
form which contains:

<%= select(:user, :state_id, @states) %>

The only problem is that the fieldWithErrors div won't get added if
nothing is selected.

If I change it too:

<%= select(:user, :state, @states) %>

I get the error:

State expected, got String

Does rails have a graceful way of doing this?
Posted by Frank -- (foo-bar)
on 18.09.2007 23:37
hi!

please have a look at my blog post, as i described the problem and a 
solution there: 
http://blog.invalidobject.com/2007/09/16/rails-error-wrapping-for-select-input-fields-of-referenced-models/

regards,
 frank

flukus@gmail.com wrote:

> I've been trying to work out the rails way of handling this. I have my
> form which contains:
> 
> <%= select(:user, :state_id, @states) %>
> 
> The only problem is that the fieldWithErrors div won't get added if
> nothing is selected.
> 
> If I change it too:
> 
> <%= select(:user, :state, @states) %>
> 
> I get the error:
> 
> State expected, got String
> 
> Does rails have a graceful way of doing this?