我有一个国家的属性,我的指导模式。我不想使用插件,我只想把国家作为一个字符串。在我尝试编辑activeadmin中的指南之前,一切都在进行,然后得到错误消息:
ActionView::Template::Error (要使用:country输入,请安装一个country_select插件,如:https://github.com/jamesds/country-select):1: insert_tag renderer_for(:编辑)
以我的形式
<%= f.input :country, as: :string%>在我的管理/指南中
index do
column :title
column :specialty
column :content
column :hospital
column :country
column :user
default_actions
end发布于 2013-10-23 18:43:30
我不知道这些表单代码是从哪里来的,但我在Active Admin中遇到了同样的问题,并通过显式指示表单将字段视为字符串来解决它:
ActiveAdmin.register Guideline do
form do |f|
f.inputs 'Details' do
f.input :country, :as => :string
end
f.actions
end
end发布于 2014-03-17 11:39:49
首先,您需要在GemFile中添加gem
gem 'country-select'创建一个助手文件‘/app/helpers/active_admin/view_helper.rb’。添加以下代码
module ActiveAdmin::ViewsHelper
def country_dropdown
ActionView::Helpers::FormOptionsHelper::COUNTRIES
end
end 在您的视图文件中使用
form do |f|
f.inputs do
f.input :country, as: :select, collection: country_dropdown
end
f.actions
end发布于 2014-05-09 06:10:37
使用country_select。如果您最近正在这样做,那么Rails 4.1似乎运行得很好。加上Rails的旧回购链接到这一个,而不是国家选择。
https://stackoverflow.com/questions/15536606
复制相似问题