# Very simple country select

**URL:** <https://www.ruby-forum.com/t/very-simple-country-select/115081>\
**Category:** Rails\
**Created:** [September 20, 2007, 1:40pm UTC](https://www.ruby-forum.com/t/very-simple-country-select/115081 "2007-09-20T13:40:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jandot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jandot](https://www.ruby-forum.com/u/jandot)\
**Post date:** [September 20, 2007, 1:40pm UTC](https://www.ruby-forum.com/t/very-simple-country-select/115081/1 "2007-09-20T13:40:20Z")

</div>

Hi all,

Country select should be simple in rails, but my code below:

\<%= country\_select(:user, :country,  
{:selected=\>‘DK’,:include\_blank=\>true}) %\>

is obviously a little too simple 🙂

I get my drop-down list of countries, but the value I select on the page  
doesn’t get saved. I get no errors, but the value in my sql database  
isn’t updated. Can someone please tell me how to save the selected  
country when I press ‘submit’.

Thanks.

---

<div class="post-metadata">

**Author:** ![jandot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jandot](https://www.ruby-forum.com/u/jandot)\
**Post date:** [September 20, 2007, 4:00pm UTC](https://www.ruby-forum.com/t/very-simple-country-select/115081/2 "2007-09-20T16:00:08Z")

</div>

Jan A. wrote:

> Hi all,
> 
> Country select should be simple in rails, but my code below:
> 
> \<%= country\_select(:user, :country,  
> {:selected=\>‘DK’,:include\_blank=\>true}) %\>
> 
> is obviously a little too simple 🙂
> 
> I get my drop-down list of countries, but the value I select on the page  
> doesn’t get saved. I get no errors, but the value in my sql database  
> isn’t updated. Can someone please tell me how to save the selected  
> country when I press ‘submit’.
> 
> Thanks.

Just off the top of my head, is your select helper inside a form?

---

<div class="post-metadata">

**Author:** ![jandot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jandot](https://www.ruby-forum.com/u/jandot)\
**Post date:** [September 20, 2007, 4:08pm UTC](https://www.ruby-forum.com/t/very-simple-country-select/115081/3 "2007-09-20T16:08:24Z")

</div>

Shandy N. wrote:

> Jan A. wrote:
> 
> > Hi all,
> > 
> > Country select should be simple in rails, but my code below:
> > 
> > \<%= country\_select(:user, :country,  
> > {:selected=\>‘DK’,:include\_blank=\>true}) %\>
> > 
> > is obviously a little too simple 🙂
> > 
> > I get my drop-down list of countries, but the value I select on the page  
> > doesn’t get saved. I get no errors, but the value in my sql database  
> > isn’t updated. Can someone please tell me how to save the selected  
> > country when I press ‘submit’.
> > 
> > Thanks.
> 
> Just off the top of my head, is your select helper inside a form?

Thanks for the reply.

Yep. The complete bit of code looks like this:

\<%= head\_helper :error =\> true %\> \<%= start\_form\_tag\_helper %\> **Select country:**   
 \<%= country\_select(:user, :country, {:selected=\>'DK',:include\_blank=\>true}) %\> \<%= render\_partial 'edit', :user =\> @user, :submit =\> true %\> \<%= end\_form\_tag %\>
