# Select tag and fieldWithErrors

**URL:** <https://www.ruby-forum.com/t/select-tag-and-fieldwitherrors/87696>\
**Category:** Rails\
**Created:** [March 5, 2007, 9:57am UTC](https://www.ruby-forum.com/t/select-tag-and-fieldwitherrors/87696 "2007-03-05T09:57:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 5, 2007, 9:57am UTC](https://www.ruby-forum.com/t/select-tag-and-fieldwitherrors/87696/1 "2007-03-05T09:57:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 18, 2007, 11:37pm UTC](https://www.ruby-forum.com/t/select-tag-and-fieldwitherrors/87696/2 "2007-09-18T23:37:12Z")

</div>

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/](http://blog.invalidobject.com/2007/09/16/rails-error-wrapping-for-select-input-fields-of-referenced-models/)

regards,  
frank

removed\_email\_address@domain.invalid 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?
