Eager loading and :order produces ambiguous column error

I'm sure I saw a post about this topic a while ago, but I haven't been able to find it again.

I have this association:

  has_many :sections, :class_name => "QuestionnaireSection", :order => "position",   :dependent => :destroy, :include => :questions

but since the Question object has a position column, the query comes back with

  Mysql::Error: Column 'position' in order clause is ambiguous:

Is there a way to get round this, or do I have to make do with unordered questions?

Thanks, Gareth

Gareth Adams wrote:

I'm sure I saw a post about this topic a while ago, but I haven't been able to find it again.

I have this association:

  has_many :sections, :class_name => "QuestionnaireSection", :order => "position",   :dependent => :destroy, :include => :questions

but since the Question object has a position column, the query comes back with

  Mysql::Error: Column 'position' in order clause is ambiguous:

Is there a way to get round this, or do I have to make do with unordered questions?

    :order => 'questionnaire_sections.position'

basically, the problem is the "position" field exists in both tables and it's not sure which one you want to use. that's why mark's suggestion, which specifies which model to use, should work...