2013-01-17 148 views
-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 =「客戶」軌SQL比賽

我怎樣才能解決這個問題?

回答

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