Why doesn't this ActiveRecord link work?

In Rails 2.2.2, in my model, I have the following:

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 is:

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

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

These lines of code are actually copied from another application where everything works. In database.yml, I point to the same db that the application uses.

Any thoughts?

thanks

+3
source share
1 answer

You do not have a partition model. You must also create this model in app/models/section.rb.

0
source

Source: https://habr.com/ru/post/1709188/


All Articles