ruby-on-rails - country_select gem 错误的参数数量错误
问题描述
我把它放在我的gemfile中
gem 'country_select'
我运行捆绑安装
我把它放在我的表格中
= f.country_select(:country, priority_countries: ["US"])
然后,当我重新启动服务器并加载页面时,出现以下错误:
ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):
导轨 5.2
这是整个表格:
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
.row
.col.s12
= devise_error_messages!
.row
.input-field.col.s12
= f.text_field :city
= f.label :city
.row
.input-field.col.s12
= f.label :country
%br
= f.country_select(:country, priority_countries: ["US"])
这是错误:
ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):
20: .input-field.col.s12
21: = f.label :country
22: %br
23: = f.country_select(:country, priority_countries: ["US"])
解决方案
嗨根据用户文档
因为您使用的是设计我假设您在您的用户模型上使用它,所以您必须调用country_select("user", "country", priority_countries: ["US"])
如果您的设计模型被称为其他名称,请将 user 替换为模型名称
推荐阅读
- typescript - 你如何创建一个枚举模块?
- matplotlib - Seaborn:如何在累积的 KDE 中绘制与特定 y 值匹配的垂直线?
- c# - 在不实例化的情况下访问 GetComponent()
- javascript - 如何将 ScrollView 与嵌套的 FlatList 一起使用?
- linux - 如何修剪声音文件末尾的噪音
- angular - ag-grid : 如何从 ag-grid 的下拉列表中选择值
- reactjs - 如何使用与路由反应的三元运算符?
- vue.js - BootstrapVue - 页面加载后显示 b-modal
- solr - 如何允许匿名访问 solr 指标端点?
- python - 已编译的 EXE 中的相对文件路径