Search Results

Search found 1 results on 1 pages for 'sellis6688'.

Page 1/1 | 1 

  • RoR ActiveRecord f.select nil method error

    - by sellis6688
    Whenever I use an f.select statement to determine assignment_id(or student_id), and I should get a validation error, I get this error instead of the validation message: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.collect Extracted source (around line #11): 8: </p> 9: <p> 10: <%= f.label 'Assignment:' %><br /> 11: <%= f.select(:assignment_id, @assignments.collect {|p| [p.ass_num, p.id]})%> 12: </p> 13: <p> 14: <%= f.label 'First Student:' %><br /> My grades model: class Grade < ActiveRecord::Base has_and_belongs_to_many :students belongs_to :assignment validates_presence_of :score, :assignment_id, :student_id validates_numericality_of :score, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 100, :allow_nil => true validates_uniqueness_of :student_id, :scope => :assignment_id end If I use a text_field, I don't get the error... but there's far too many students for that. Neither @assignments nor @students are nil. Any suggestions?

    Read the article

1