本文介绍了不明确的表引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这个问题似乎很简单,但我从来没有遇到过一个像这样。This problem seems fairly simple, but I've never encountered one like this.下面是设置:Post has_many :reader_linksPost has_many :readers, :through => :reader_links我需要找出是否有读者阅读文章。I need to find out if there are readers reading a post. @ post.reader_links.where('created_at> =',45.minutes.ago)?.ANY的伟大工程。 @ post.readers.where('created_at> =',45.minutes.ago)?,任何引发的暧昧表列的错误,因为它混淆是否 created_at 列意味着读者对象或 reader_link 对象。这是因为类读者实际上是用户。如何查询读者谁被reader_links在38分钟以前?throws an ambiguous table column error because it's confused whether the created_at column means that of reader object or reader_link object. This happens because the class of a reader is actually User. How do I query readers who were created by reader_links 45 minutes ago?我正在寻找像.. @ post.readers.where('reader_link.created_at> =',45.minutes.ago)推荐答案如果我得到它的权利,你只需要指定 created_at 列你在谈论:If I get it right, you just need to specify which created_at column you're talking about:@post.readers.where('reader_links.created_at >= ?', 45.minutes.ago).any? 这篇关于不明确的表引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 18:16