大家好我正在尝试安装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 %>
非常感谢任何帮助,谢谢!
答案 0 :(得分:0)
您需要将country_code和state_code添加到users表。
rails g migration addCountryCodeToUser country_code:string state_code:string
rake db:migrate