Sha256: a1afd506f0990f81e3fef3740fe48d319e14b77fe9d3984b031289118c5d6cf2

Contents?: true

Size: 454 Bytes

Versions: 3

Compression:

Stored size: 454 Bytes

Contents

module Notee
  class Post < ActiveRecord::Base

    # callbacks
    before_create :set_title
    before_create :set_slug

    # relations
    belongs_to :category
    belongs_to :thumbnail, :class_name => Notee::Image, :foreign_key => 'thumbnail_id'

    def set_title
      self.title = "no_title#{Notee::Post.count}" unless self.title.present?
    end

    def set_slug
      self.slug = self.title.downcase unless self.slug.present?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
notee-0.3.1 app/models/notee/post.rb
notee-0.3.0 app/models/notee/post.rb
notee-0.2.9 app/models/notee/post.rb