Reputation: 3869
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
How find all clients by comment date '2012-01-30'?
Upvotes: 0
Views: 85
Reputation: 29599
assuming date
is a date type field
Client.joins(:comments).where(comments: { date: Date.new(2012,1,30) })
Upvotes: 2