Sha256: 65336f0228c4e86a6510f1215b9e250ce10d3233785bf2244d450b64714510f7

Contents?: true

Size: 526 Bytes

Versions: 1

Compression:

Stored size: 526 Bytes

Contents

module Kublog
  class Category < ActiveRecord::Base
    extend FriendlyId
    
    has_many  :posts,       :dependent => :nullify
    
    validates_presence_of   :name
    validates_uniqueness_of :name
    
    friendly_id             :name, :use => :slugged
    
    def to_s
      self.name.titleize
    end
    
    # Site access to the category
    def path
      Engine.routes.url_helpers.category_path(self)
    end
    
    def as_json(params={})
      super params.merge({:methods => [:path]})
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kublog-0.0.1.1 app/models/kublog/category.rb