app/models/user.rb
# Defines a proto-feed.
# See "Following users" for the full implementation.
Defines a proto-feed.
See "Following users" for the full implementation.
Defines a proto - feed . See " Following users " for the full implementation .
def feed
      following_ids = "SELECT followed_id FROM relationships
                     WHERE  follower_id = :user_id"
      Micropost.where("user_id IN (#{following_ids})
                     OR user_id = :user_id", user_id: id)
    end
def feed following_ids = "SELECT followed_id FROM relationships
                     WHERE  follower_id = :user_id" Micropost . where ( "user_id IN (#{following_ids})
                     OR user_id = :user_id" , user_id : id ) end
Defines a proto-feed.
Defines a proto - feed .
# Placeholder - not real but populates the UI. # microposts  # Works, but not great in large sets. # Micropost.where("user_id IN (?) OR user_id = ?", following_ids, id) # Works, but the IDs are interpolated, not escaped. # Micropost.where("user_id IN (:following_ids) OR user_id = :user_id", #               following_ids: following_ids, user_id: id) # Final Implementation