Model Single Responsibility

Sometimes using a model inside another model can be a red flag:

def timeline_shouts
  Shout.where(user_id: followed_user_ids + [id])
end

Good questions to ask:

  • should this live in the User model?
  • should this live in the Shout model?
  • is there a different domain object that can be extracted to better encapsulate this concept?