carmen_rails country_select错误的参数数量(3表示0)

And*_*oup 7 ruby-on-rails carmen

试图让carmen_rails启动并运行以将国家和子区域(州)添加到我的家庭用户注册中并遇到一个问题我在任何在线搜索中都没有得到任何帮助(至少从我能找到的内容).

安装

gem 'carmen-rails', '~> 1.0.0'
Run Code Online (Sandbox Code Playgroud)

遵循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 %>
Run Code Online (Sandbox Code Playgroud)

我目前正在使用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>
Run Code Online (Sandbox Code Playgroud)

来自app/models/user.rb的验证部分

validates :country, presence: true
validates :subregion, presence: true
Run Code Online (Sandbox Code Playgroud)

我得到下面的错误,无法找出根本原因或解决方案.任何帮助是极大的赞赏!

wrong number of arguments (3 for 0)
Run Code Online (Sandbox Code Playgroud)

我收到下面的错误,但认为它是通过重新启动rails服务器解决的

undefined method `country_select' for ..
Run Code Online (Sandbox Code Playgroud)

loo*_*vis 21

我今天也有同样的问题.经过一番挖掘,看来这个问题已在源代码中得到修复,但gem尚未在RubyGems.org上更新.

修改你的GEMFILE直接从Github拉:

??gem 'carmen-rails', '~> 1.0.0', github: 'jim/carmen-rails'
Run Code Online (Sandbox Code Playgroud)

然后运行bundle install,然后bundle clean删除旧版本,然后重新启动服务器.Github版本和RubyGems.org版本是相同的,令人困惑,但这解决了它.