SimpleForm not recognising country attribute for my model

Posted by Ife Odugbesan

7 months ago

0

gem gemfile simple-form country rails

Error message:

undefined method `country_select' for #


When you have a field name country, the simple_form will try to use the country_select. You can override that by adding the following code to the simple_form.rb initializer:

config.input_mappings = { /country/ => :string }
Otherwise if you would like to use the country select gem that will generate a list of countries for you, you can add this gem to the gemfile.rb:

gem 'country_select', '~> 8.0'
Then use it in your form:

<%= simple_form_for @model_instance do |f| %>

  <%= f.country_select :country %>

<% end %>