开发者

Ruby on Rails: Search logic query gives MySQL ambiguous column error

Sear开发者_StackOverflowch logic is automagically doing an INNER JOIN on one the tables in my DB, is there a way to get it to specify to not include the user column in that second table?


Possibly, but that's a complicated (and therefore not the best) solution to your ambiguous column problem. The ambiguity occurs presumably because you have some conditions referrring to a column name and both tables have that column. The proper way to deal with that is to simply specify the table names in your query, like

@topics = Topic.find(:all, :include => [:posts], :conditions => ["topics.user_id <> ?", current_user.id])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜