2015-12-11 57 views
0

我保存記錄時,進入數據庫後,我加入了新列的遷移是「fathername」Ruby on Rails的節能記錄產生問題

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列已經存在,但面臨着以下錯誤的顯示錯誤請幫助,我不知道什麼是錯的?

+0

有你加入'fathername'在strong_parameters?我假設你正在使用Rails 4. – Dusht

+0

添加student_controller.rb的詳細信息@Naveed –

+0

不,我不知道如何在strong_parameters中添加,並且我正在使用rails 2.3.5 – Naveed

回答

0

我想你只需要運行遷移rake db:migrate!當您嘗試設置屬性值並且此屬性列在數據庫中不存在時,通常會發生這種情況。

希望它能幫助:)