Commits

heliostatic committed 0b427f8

Finished base of user following

  • Participants
  • Parent commits fe87734

Comments (0)

Files changed (1)

File app/models/micropost.rb

   default_scope order: 'microposts.created_at DESC'
 
   def self.from_users_followed_by(user)
-    followed_user_ids = user.followed_user_ids
-    where("user_id IN (?) OR user_id = ?", followed_user_ids, user)
+    followed_user_ids = "SELECT followed_id FROM relationships
+                         WHERE follower_id = :user_id"
+    where("user_id IN (#{followed_user_ids}) OR user_id = :user_id", user_id: user)
   end
 end