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
Mark_James
(Mark James)
September 7, 2006, 1:45pm
2
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'
Curtis
(Curtis)
September 8, 2006, 2:34pm
3
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...