To use the input: country, install the country_select plugin

I have a country attribute for my recommendation model. I do not want to use the plugin, I just want to have the country as a string. Everything works until I try to edit the directive in activeadmin, and then I get an error message:

ActionView :: Template :: Error (To use the input: country, please install the country_select plugin like this: https://github.com/jamesds/country-select ): 1: insert_tag renderer_for (: edit)

in my form I have

<%= f.input :country, as: :string%> 

in my admin / guidelines.rb I have

 index do column :title column :specialty column :content column :hospital column :country column :user default_actions end 
+4
source share
6 answers

I'm not sure where you get the code for this form from, but I had the same problem with Active Admin and resolved it by explicitly specifying the form for processing the field as a string:

 ActiveAdmin.register Guideline do form do |f| f.inputs 'Details' do f.input :country, :as => :string end f.actions end end 
+13
source

First you need to add the gem to the GemFile

 gem 'country-select' 

Create a helper file '/app/helpers/active_admin/views_helper.rb'. Add code below

 module ActiveAdmin::ViewsHelper def country_dropdown ActionView::Helpers::FormOptionsHelper::COUNTRIES end end 

In your view file use

 form do |f| f.inputs do f.input :country, as: :select, collection: country_dropdown end f.actions end 
+4
source

Use country_select . Seems to work great with Rails 4.1 if you are doing this recently. Plus, Rails has an old repo link to this option, not a country choice.

+1
source

ActiveAdmin is used, so you are also using Formtastic .

In Formtastic, the formtastic / lib / formtastic / input / country_input.rb file clearly states:

 # Rails doesn't come with a `country_select` helper by default any more, so you'll need to do # one of the following: # # * install the [country_select](https://github.com/stefanpenner/country_select) gem # * install any other country_select plugin that behaves in a similar way # * roll your own `country_select` helper with the same args and options as the Rails one 

I would add the gem 'country-select' to your Gemfile and install the package as it is the easiest and fastest solution.

0
source

I assume that you can set the gem and then override the display in active_admin.

-1
source

I recommend you use country-select :

 gem 'country-select' 

I spent many hours to find out why country-select does not work on my form :)

-4
source

All Articles