class Subcreddit < ActiveRecord::Base extend FriendlyId belongs_to :owner, class_name: 'User' has_many :posts friendly_id :name, use: :slugged attr_accessor :closed delegate :username, to: :owner, prefix: true before_save :set_closed_at validates :name, presence: true, format: /\A(?! )[a-z0-9 ]*(?