class Client < ActiveRecord::Base
attr_accessible :name
has_many :comments, :dependent => :destroy
end
class Comment < ActiveRecord::Base
attr_accessible :title, :date
belongs_to :client
end
如何按评论日期查找所有客户&#39; 2012-01-30&#39;?
答案 0 :(得分:2)
假设date
是日期类型字段
Client.joins(:comments).where(comments: { date: Date.new(2012,1,30) })