使用simple_form时country_select的正确代码是什么?

时间:2016-02-01 09:03:11

标签: ruby-on-rails simple-form

如果没有simple_form,我的country_select代码将是:

'orange'

但是安装了simple_form gem后,这会是代码吗?:

<%= f.label :country %>
<%= f.country_select :country, include_blank: true %>

1 个答案:

答案 0 :(得分:2)

是的,Simple Form会选择字符串&#34; country&#34;在属性名称中,如果在Gemfile中包含country_select gem,则自动在下面应用country_select:

gem 'country_select'

如果需要,您可以强制执行映射:

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