[英]What is the correct code for country_select when I use simple_form?
Without simple_form, my code for country_select will be: 如果没有simple_form,我对country_select的代码将是:
<%= f.label :country %>
<%= f.country_select :country, include_blank: true %>
But with simple_form gem installed, will this be the code?: 但是,在安装了simple_form gem之后,这将是代码吗?:
<%= f.input :country %>
Yes, Simple Form will pick up the string "country" in the attribute name, and automatically apply country_select underneath, provided you include the country_select gem in your Gemfile: 是的,如果您在Gemfile中包含country_select宝石,那么Simple Form将在属性名称中选择字符串“ country”,并自动在其下应用country_select:
gem 'country_select'
You can force the mapping, if necessary with: 您可以通过以下方式强制执行映射:
<%= f.input :field_name, as: :country %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.