我有一个有很多选票的候选人.
我想获得本月创建的候选人的投票?
@candidate.votes.from_this_month
scope :from_this_month, where("created_at > ? AND created_at < ?", Time.now.beginning_of_month, Time.now.end_of_month)
Run Code Online (Sandbox Code Playgroud)
这给了我一个PG错误:PG ::错误:错误:列引用\"created_at \"是不明确的
如果我试试
scope :from_this_month, where("vote.created_at > ? AND vote.created_at < ?", Time.now.beginning_of_month, Time.now.end_of_month)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
PG::Error: ERROR: missing FROM-clause entry for table "vote"
Run Code Online (Sandbox Code Playgroud)