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
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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With