I keep getting: NoMethodError in StudentsController
undefined method `id_num=' for #<Array:0x105adcc98>
I'm positive there's an id_num in table and it's occuring in the controller:
Students Controller:
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
This may look a little confusing but because when the test! method is called in the Student model, the student will be assigned a testing_id, I can't perform a condition between student and book until the student is assigned a random testing_id value. So the book must be identified after test!. That's why the find is done there.