मैं एक परीक्षण में एक Student
रिकॉर्ड बनाने के लिए कोशिश कर रहा हूँ इस तरह:रेल 3.1, मुझे ActiveRecord क्यों मिलता है :: अज्ञात एट्रिब्यूट त्रुटि: spec test में अज्ञात विशेषता?
student= Student.create!(:work_phone => "1234567890")
लेकिन मैं इस त्रुटि मिलती है:
ActiveRecord::UnknownAttributeError: unknown attribute: work_phone
हालांकि, work_phone
Student
मॉडल में परिभाषित किया गया है, और चले गए।
class Student < ActiveRecord::Base
validates_length_of :work_phone, :is => 10, :message => 'must be 10 digits, excluding special characters such as spaces and dashes. No extension or country code allowed.', :if => Proc.new{|o| !o.work_phone.blank?}
attr_accessible:work_phone
end
किसी भी विचार:
यहाँ Student
मॉडल है?
हां, यही कारण है कि, मुझे, attr_accessor जोड़ने की ज़रूरत है: मॉडल के लिए work_phone, धन्यवाद – simo
'रेक डीबी: टेस्ट: तैयार' के साथ परीक्षण डेटाबेस तैयार करना धन्यवाद, धन्यवाद। –