-2
customer = Feedback.includes(:user).where("('created_at' >= ? and 
'created_at' < ? and how_did_you_hear = ? and 
users.user_type = ? )",date_start,date_end,value,"customer").count

此代码不仅与所有反馈匹配 Feedback.user.user_type = "customer"

我怎样才能解决这个问题?

4

1 回答 1

0

这可以工作:

customer = Feedback.includes(:user).where("feedbacks.created_at >= ? AND feedbacks.created_at < ? AND how_did_you_hear = ? AND users.user_type = 'customer'", date_start, date_end, value).count
于 2013-01-17T15:44:58.473 回答