Rails formtastic is asking for a country plug-in.. I don't want it. Anyone know how to tell it I don't want it?
-
30-06-2021 - |
Question
I'm using formtastic and I've got a field country.. I'm getting this error when I attempt to display the screen.
To use the :country input, please install a country_select plugin, like this one: https://github.com/jamesds/country-select
Now. I don't want to use any plugin.. It's free text, and I want to keep it that way.
Anyone know how to remove this requirement? Should be easy as... but I'm buggered if I can see how.
= semantic_form_for @store, {:html => { :class => "form-horizontal" }} do |f|
= f.input :default_country
Solution
Add , :as => :string
to the end of the line that's causing the error
= semantic_form_for @store, {:html => { :class => "form-horizontal" }} do |f|
= f.input :default_country, :as => :string
OTHER TIPS
In Rails 4, formtastic with country select input field:
Add 'country-select' to your Gemfile:
gem 'country-select'
If I use semantic form select, it doesn't shows previously saved value. So, the following is not working properly:
=f.input :country, as: :select, collection: country_options_for_select
So have to use standard form elements to get working:
=f.select :country, collection: country_options_for_select
I found that this plugin works out of the box (note the underscore instead of the dash):