1
我不斷收到:NoMethodError在StudentsControllerNoMethodError /未定義的方法
undefined method `id_num=' for #<Array:0x105adcc98>
我敢肯定有一個在表中的ID_NUM和它存在的控制器:
學生控制器:
def student_test
@student = Student.find(params[:id]) if params[:id]
@student ||= Student.new
run_sequence :testize
end
def test_finalize
Student.transaction do
if @student.update_attributes(params[:student]) && @student.test!
x = @student.site_id
y = @student.testing_id
book = Book.find(:all, :conditions => ["location_id = ? AND testing_id = ?", x, y])
room = Room.new(:room_num => 5)
room.save
book.id_num = room.id #error occurs here. Book.new would work. But I need to do a find.
book.save
end
end
這可能看起來有點令人困惑,但因爲當測試!方法在學生模型中被調用,該學生將被分配一個testing_id,我不能在學生和書籍之間執行一個條件,直到給學生分配一個隨機的testing_id值。所以這本書必須經過測試後才能確定!這是 爲什麼在那裏找到了。