So ive searched and can’t find a existing question that has helped me with this.
I have a model:
class ClassComments < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :user
belongs_to :class, :class_name => 'Clas'
end
And when I call c = ClassComments.new in my controller I get this error:
undefined method `[]' for nil:NilClass
Any ideas on what is causing this? I’m stumped!
Changing the class name to something other than
ClasorClasswill fix the issue since class it is a reserved word in ruby/rails.Source:
http://latheesh.com/2010/02/02/rails-reserved-words/