Sha256: e0c8943b41d75fbcd2c39438b6438611acdefb914bf78546f1096d36bfcbf9d0

Contents?: true

Size: 399 Bytes

Versions: 6

Compression:

Stored size: 399 Bytes

Contents

module MechanizeStore
  class ProductCategory < ActiveRecord::Base
    belongs_to :product_section
    
    has_many :products

    validates :name, presence: true

    after_create :create_slug
    before_update :set_defaults

    def set_defaults
      self.slug = self.name.parameterize
    end

    def create_slug
      self.update_attributes(:slug => self.name.parameterize)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mechanize_store-0.0.19 app/models/mechanize_store/product_category.rb
mechanize_store-0.0.18 app/models/mechanize_store/product_category.rb
mechanize_store-0.0.17 app/models/mechanize_store/product_category.rb
mechanize_store-0.0.16 app/models/mechanize_store/product_category.rb
mechanize_store-0.0.15 app/models/mechanize_store/product_category.rb
mechanize_store-0.0.14 app/models/mechanize_store/product_category.rb