Sha256: dd263cbf23cfc27b4c6d87852bf040ca4f05b52f263f5704678d9f49afd37084
Contents?: true
Size: 542 Bytes
Versions: 13
Compression:
Stored size: 542 Bytes
Contents
class Micropost < ActiveRecord::Base belongs_to :user default_scope -> { order('created_at DESC') } validates :content, presence: true, length: { maximum: 140 } validates :user_id, presence: true # Returns microposts from the users being followed by the given user. def self.from_users_followed_by(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.id) end end
Version data entries
13 entries across 13 versions & 2 rubygems