rubygemscarmen

Carmen-Rails gem error undefined method 'country_code'


Hello everyone I am trying to install the carmen-rails gem and keep getting the error "Undefined method 'country_code'

My controller:

    def new
    @user = User.new
end
def create
    @user = User.create( :country_code, :state_code )
end

My User model:

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable


end

My Views page:

<h1>Hello!</h1>
<p>Welcome to my App</p>

<%= simple_form_for(User.new) do |f| %>
  <%= f.input :country_code do %>
    <%= f.country_select :country_code, {object: f.object, prompt: 'Country'} %>
  <% end %>
<% end %>

Any help would be greatly appreciated, thanks!


Solution

  • your need to add country_code and state_code to the users table.

    rails g migration addCountryCodeToUser country_code:string state_code:string
    rake db:migrate