Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make country default in form as "United States"

I am trying to make the default value for the country input in a form to be "United States". I am using the simple form gem and country select gem.

In the simple form initializer, I set this default

  config.country_priority = [ "United States" ]

Which makes the topmost value correct as United States, but the default value is 'Uganda'.

In the _form view, I did the following:

<%= f.input :country, :default => [ 'United States' ] %>

I restarted Rails and it still defaulted to Uganda.

I also tried the following:

<%= f.input :country, :default => 'United States' %>

and

<%= f.input :country, :selected => 'United States' %>

What should I try next?

like image 585
Castielle Avatar asked Dec 31 '12 23:12

Castielle


2 Answers

Try this,

<%= form.country_select :country, ["United States"] %>
like image 95
shweta Avatar answered Sep 29 '22 08:09

shweta


I tried this with gem 'country_select' in simple-form. It's worked for me.

= f.input :country,  priority: [ "Brazil" ]
like image 39
Kannan S Avatar answered Sep 29 '22 06:09

Kannan S