Sha256: 36cde4d6170b225f34e78ead07c67b8e9f8f4289d46b589505c356cea4d15107
Contents?: true
Size: 555 Bytes
Versions: 2
Compression:
Stored size: 555 Bytes
Contents
class Post < ActiveRecord::Base before_save :set_url belongs_to :user default_scope order('created_at DESC') validates_presence_of :name, :message => 'Your post needs a name' validates_uniqueness_of :name, :message => 'A post with that name already exists' class << self def extract_month(attribute) "strftime('%m', #{attribute})" end def extract_year(attribute) "strftime('%Y', #{attribute})" end end # def to_param # url # end protected def set_url self.url ||= name.parameterize end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grandstand-0.2.2 | app/models/post.rb |
grandstand-0.2.1 | app/models/post.rb |