0

大家好,我正在尝试安装 carmen-rails gem 并不断收到错误“未定义的方法 'country_code'

我的控制器:

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

我的用户模型:

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

我的观点页面:

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

任何帮助将不胜感激,谢谢!

4

1 回答 1

0

您需要将 country_code 和 state_code 添加到 users 表中。

rails g migration addCountryCodeToUser country_code:string state_code:string
rake db:migrate
于 2014-09-12T02:31:32.400 回答