Question

Trying to get carmen_rails up and running to add country and subregion(state) to my home-rolled user registration and came across an issue I'm having w/ little help from any online searches (at least from what I can find).

Installed

gem 'carmen-rails', '~> 1.0.0'

Following the github instructions (https://github.com/jim/carmen-rails), the following code should be inserted into my registration page:

<%= simple_form_for @user do |f| %>
  <%= f.input :country_code do %>
    <%= f.country_select :country_code, {object: f.object, prompt: 'Country'} %>
  <% end %>
<% end %>

I'm currently using Rails 4.0.0 and Bootstrap 3 RC2 so my registration code looks like this (along with the standard form setup):

<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>

and validation section from app/models/user.rb

validates :country, presence: true
validates :subregion, presence: true

I get the error below and can't figure out the root cause or resolution. Any help is greatly appreciated!

wrong number of arguments (3 for 0)

I was getting the error below, but think it was resolved by restarting the rails server

undefined method `country_select' for ..
Was it helpful?

Solution

I had this same issue today. After a little digging, it appears that this issue has been fixed in the source, but that the gem has not been updated at RubyGems.org.

Modify your GEMFILE to pull directly from Github:

gem 'carmen-rails', '~> 1.0.0', github: 'jim/carmen-rails'

Then run bundle install, then bundle clean to remove the older version, and then restart your server. The Github version and the RubyGems.org version are the same which is confusing, but this solved it for me.

OTHER TIPS

In my case, the offender was Active Scaffold. I got rid of it adding this:

ActiveScaffold.exclude_bridges = [:country_helper]

in config/initializers/active_scaffold.rb

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top