Sha256: b93c12476b4e263ba6b0bf847d92161e331e2926d3fbf637426f14bbb03d552d
Contents?: true
Size: 611 Bytes
Versions: 2
Compression:
Stored size: 611 Bytes
Contents
module RailsMarketplace class Category < ActiveRecord::Base extend ActsAsTree::TreeWalker include FriendlyId friendly_id :name, :use => :slugged has_many :category_products, :dependent => :destroy, :autosave => true , :inverse_of => :category accepts_nested_attributes_for :category_products, :allow_destroy => true, :reject_if => :all_blank has_many :products, :through => :category_products acts_as_tree order: 'parent_id' def should_generate_new_friendly_id? name_changed? end def self.root_categories where(parent_id: nil).order('id asc') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_marketplace-0.0.2 | app/models/rails_marketplace/category.rb |
rails_marketplace-0.0.1 | app/models/rails_marketplace/category.rb |