试图使carmen_rails启动并运行以添加国家和次区域(州)到我的家庭滚动用户注册,并遇到一个问题,我在任何在线搜索(至少从我所能找到的)几乎没有帮助。
已安装
gem 'carmen-rails', '~> 1.0.0'按照github指令(https://github.com/jim/carmen-rails),应将以下代码插入我的注册页面:
<%= simple_form_for @user do |f| %>
<%= f.input :country_code do %>
<%= f.country_select :country_code, {object: f.object, prompt: 'Country'} %>
<% end %>
<% end %>我目前使用的是Rails 4.0.0和Bootstrap 3 RC2,所以我的注册代码如下(以及标准表单设置):
<div class="form-group">
<%= f.label :country, class: "col-md-4 control-label" %>
<div class="col-md-8">
<%= f.country_select :country, {priority: %w(US CA), prompt: "Please select a country", class: "form-control"} %>
</div>
</div>和app/model/user.rb中的验证部分
validates :country, presence: true
validates :subregion, presence: true我得到了下面的错误,无法找出根本原因或解决办法。任何帮助都是非常感谢的!
wrong number of arguments (3 for 0)我得到了下面的错误,但认为通过重新启动rails服务器解决了错误。
undefined method `country_select' for ..发布于 2013-08-30 01:20:43
我今天也有同样的问题。经过一点挖掘,这个问题似乎已经在源代码中得到了解决,但是gem还没有在RubyGems.org上被更新。
修改您的GEMFILE以直接从Github中提取:
gem 'carmen-rails', '~> 1.0.0', github: 'jim/carmen-rails'然后运行bundle install,然后运行bundle clean以删除旧版本,然后重新启动服务器。Github版本和RubyGems.org版本是相同的,这是令人困惑的,但这为我解决了它。
发布于 2014-07-10 13:06:48
在我的案件中,罪犯是活跃的脚手架。我把它处理掉了,补充说:
ActiveScaffold.exclude_bridges = [:country_helper]在config/initializers/active_scaffold.rb中
https://stackoverflow.com/questions/18518850
复制相似问题