2010-12-26 12 views
1

最終日に作成されたポジションを持つスキルを購読しているユーザーを見つけるにはどうすればよいですか?結合モデルを介して属性を検索する方法は?

私は可能性がしたい

:User.find(すべて).where.skills.positions -

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 => :subscriptions 

答えて

1

私は「よく分からない(、Time.now 1.day 'のcreated_at>?')あなたの答えを完全に理解しましたが、できるはずです

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]) 

希望すると助かります。

+0

ありがとうございました!できます。私は "include({:skills =>:positions}"についてもっと学ぶべきです。 –

関連する問題