# Issues with us\_states and selected

**URL:** <https://www.ruby-forum.com/t/issues-with-us-states-and-selected/120684>\
**Category:** Rails\
**Created:** [November 19, 2007, 7:27pm UTC](https://www.ruby-forum.com/t/issues-with-us-states-and-selected/120684 "2007-11-19T19:27:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thoraxe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9dc877/32.png) [@thoraxe](https://www.ruby-forum.com/u/thoraxe)\
**Post date:** [November 19, 2007, 7:27pm UTC](https://www.ruby-forum.com/t/issues-with-us-states-and-selected/120684/1 "2007-11-19T19:27:07Z")

</div>

I’m having some issues with the us\_states plugin but it is probably  
because I don’t know what I’m doing.

Here’s my code:

\<% form\_tag ‘/contact/list’ do -%\>  
\<%= text\_field\_tag “searchName”, “”, :size =\> 15, :maxlength =\> 50 -  
%\>\<%= submit\_tag “Search” %\>  
\<% if !params[:state].nil? %\>  
\<%= us\_state\_select(“state”, “abbr”, {:include\_blank =\>  
true, :selected =\> params[:state][:abbr]}) %\>  
\<% else %\>  
\<%= us\_state\_select(“state”, “abbr”, {:include\_blank =\> true}) %\>  
\<% end %\>  
\<% end -%\>

* * *
\<%= debug params %\>

I’ve tried various incarnations of the :selected option and am at a  
loss. :include\_blank works just fine, though.

Does anyone have any suggestions?

---

<div class="post-metadata">

**Author:** ![thoraxe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9dc877/32.png) [@thoraxe](https://www.ruby-forum.com/u/thoraxe)\
**Post date:** [November 19, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/issues-with-us-states-and-selected/120684/2 "2007-11-19T21:18:43Z")

</div>

I changed to using a select\_tag and this seems to have fixed my  
issue. I’m not sure why it didn’t work before, though:

\<%= select\_tag( :state,  
us\_state\_options\_for\_select(params[:state], :include\_blank =\> true) )  
%\>
