Sha256: 8e41b6c9412f1974e13fdc0390e2676042434e1f208d49c6c0befe63e84c6313

Contents?: true

Size: 431 Bytes

Versions: 7

Compression:

Stored size: 431 Bytes

Contents

module Notee
  class Category < ActiveRecord::Base

    # callbacks
    before_save :set_slug
    before_destroy :protect_default

    # relations
    has_many :children, class_name: Notee::Category, :foreign_key => 'parent_id', dependent: :destroy


    private

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

    def protect_default
      return false if self.id == 1
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
notee-0.3.7 app/models/notee/category.rb
notee-0.3.6 app/models/notee/category.rb
notee-0.3.5 app/models/notee/category.rb
notee-0.3.4.1 app/models/notee/category.rb
notee-0.3.4 app/models/notee/category.rb
notee-0.3.3 app/models/notee/category.rb
notee-0.3.2 app/models/notee/category.rb