Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To use the :country input, please install a country_select plugin

I have a country attribute to my guidelines model. I don't want to use a plugin, I just want to have country as a string. Everything is working until I try to edit a guideline in activeadmin and then I get the error message:

ActionView::Template::Error (To use the :country input, please install a country_select plugin, like this one: 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
like image 713
tessad Avatar asked Mar 20 '13 23:03

tessad


3 Answers

I'm not sure where you get this form code from but I had the same issue with Active Admin and resolved it by explicitly instructing the form to treat 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
like image 71
Michi Gysel Avatar answered Nov 20 '22 22:11

Michi Gysel


First you need to add the gem in GemFile

gem 'country-select'

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

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
like image 40
Amal Kumar S Avatar answered Nov 20 '22 21:11

Amal Kumar S


Use country_select. Seems to work fine with Rails 4.1 if you're doing this recently. Plus Rails old repo links to this one rather than country-select.

like image 1
Allen Avatar answered Nov 20 '22 21:11

Allen