ruby on rails保存记录会产生问题

时间:2015-12-11 11:56:38

标签: ruby-on-rails

将新列添加到“fathername”的迁移后,我将记录保存到数据库中时遇到以下错误

 NoMethodError in StudentController#admission1

undefined method `fathername=' for #<User:0x7ffcd42a3a40>

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:255:in `method_missing'
/root/ansipro342/app/models/student.rb:141:in `create_user_and_validate'
/root/ansipro342/app/controllers/student_controller.rb:62:in `admission1'

Request

Parameters:

{"student"=>{"first_name"=>"Salman",
 "fatheroccupation"=>"Lecturer",
 "address_line1"=>"",
 "address_line2"=>"",
 "country_id"=>"141",
 "roll_num"=>"100",
 "is_email_enabled"=>"1",
 "gender"=>"m",
 "fathernic"=>"",
 "biometric_id"=>"",
 "admission_date"=>"2015-12-11",
 "date_of_birth"=>"2010-12-11",
 "fathername"=>"Kamran",
 "nationality_id"=>"141"}

即使是fathername列已经存在但是它显示错误请帮忙,我不知道出了什么问题?

1 个答案:

答案 0 :(得分:0)

我认为您只需要运行迁移rake db:migrate!当您尝试设置属性值并且此属性列不存在于数据库中时,通常会发生这种情况。

希望有所帮助:)