I have a candidate who has_many votes.
Am I trying to get the votes of a candidate created this month?
@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)
This gives me the error PG: PG :: Error: ERROR: the column reference \ "created_at \" is ambiguous
If i try
scope :from_this_month, where("vote.created_at > ? AND vote.created_at < ?", Time.now.beginning_of_month, Time.now.end_of_month)
I get the following error
PG::Error: ERROR: missing FROM-clause entry for table "vote"
source
share