vrfs-774: added top_followings; removed order_by from user_followings; fixed inverse_likes association typo which used :through => :followings instead of :through => :likes
This commit is contained in:
parent
2c7d7bb5a4
commit
ac2d4770f5
|
|
@ -46,7 +46,7 @@ module JamRuby
|
|||
|
||||
# user likes (fans and musicians have likes)
|
||||
has_many :likes, :class_name => "JamRuby::UserLike", :foreign_key => "liker_id", :inverse_of => :user
|
||||
has_many :inverse_likes, :through => :followings, :class_name => "JamRuby::User", :foreign_key => "user_id"
|
||||
has_many :inverse_likes, :through => :likes, :class_name => "JamRuby::User", :foreign_key => "user_id"
|
||||
|
||||
# band likes
|
||||
has_many :band_likes, :class_name => "JamRuby::BandLiker", :foreign_key => "liker_id", :inverse_of => :user
|
||||
|
|
@ -59,7 +59,7 @@ module JamRuby
|
|||
has_many :inverse_followers, :through => :inverse_user_followers, :source => :user, :class_name => "JamRuby::User"
|
||||
|
||||
# user followings
|
||||
has_many :user_followings, :class_name => "JamRuby::UserFollowing", :foreign_key => "follower_id", :order => 'created_at DESC'
|
||||
has_many :user_followings, :class_name => "JamRuby::UserFollowing", :foreign_key => "follower_id"
|
||||
has_many :followings, :through => :user_followings, :class_name => "JamRuby::User"
|
||||
has_many :inverse_user_followings, :through => :followings, :class_name => "JamRuby::UserFollowing", :foreign_key => "user_id"
|
||||
has_many :inverse_followings, :through => :inverse_user_followings, :source => :user, :class_name => "JamRuby::User"
|
||||
|
|
@ -979,8 +979,12 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
attr_accessor :search_counters
|
||||
|
||||
def top_followings
|
||||
@topf ||= User.joins("INNER JOIN users_followers AS follows ON follows.user_id = users.id")
|
||||
.where(['follows.follower_id = ?',self.id])
|
||||
.order('follows.created_at DESC')
|
||||
.limit(3)
|
||||
end
|
||||
|
||||
# devise compatibility
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue