views:

94

answers:

1

In Rails 2.2.2 In my model I have this:

class Question < ActiveRecord::Base
  set_table_name "t346128_question"
  set_primary_key "question_id"
  has_many :sections, :order => 'position, section_id', :dependent => :destroy
  ...
end

And in my controller, this:

def answer()
   @question = Question.find(params[:id])
   puts "question=#{@question.name}..."
   puts "sections=#{@question.sections.size}..." # <<== THIS FAILS
   render :layout => false
end

The line with @question.sections fails with "uninitialized constant Question::Section"

These lines of code are actually copied from another app where it all works. In database.yml I'm pointing to the same db that app uses.

Any thoughts?

Thanks

+1  A: 

Will assumed wrong! The Section model was not properly defined. Thanks Will.

Paul
Actually I was the one who assumed that. Will just editing your question. =P
Marc W