Rails Error :Column 'id' in order clause is ambiguous

错误Column 'id' in order clause is ambiguous 易出现在
=  Product.find(:all,:include => :kind,:order => " id desc " )
类似的语句上,用include包含了一个left join对象,所以id可能存在于多个表内,就引起了二义性
修改为
=  Product.find(:all,:include => :kind,:order => " products.id desc " )
属性前加上表名
一切OK

转载于:https://www.cnblogs.com/Tachikoma/archive/2008/03/07/1095829.html

你可能感兴趣的:(Rails Error :Column 'id' in order clause is ambiguous)