How do I find users who are subscribed to skills which have positions created in the last day?
I wish I could: User.find(all).where.skills.positions('created_at > ?', Time.now - 1.day)
Company
has_many :positions
has_many :skills, :through => :positions
Position
belongs_to :company
belongs_to :skill
Skill
has_many :positions
has_many :companies, :through => :positions
has_many :subscriptions
has_many :users, :through => :subscriptions
Subscription
belongs_to :skill
belongs_to :user
User
has_many :subscriptions
has_many :skills, :through => :sub开发者_如何转开发scriptions
I'm not sure I've understood your answer completely, but you should be able to do
User.all.include({ :skills => :positions }).where(['positions.created_at > ? AND positions.created_at < ?',(Time.now - 1.day).at_beginning_of_day, (Time.now - 1.day).at_end_of_day])
Hope it helps.
精彩评论