Sha256: 9179573ed4d65d24c9d3438285f933b4609bcd41c625a4f8dbf53dff1d4e21c1

Contents?: true

Size: 787 Bytes

Versions: 4

Compression:

Stored size: 787 Bytes

Contents

module Adminpanel
  class Category < ActiveRecord::Base
    attr_accessible :name, :model

    validates_presence_of :model
    validates_presence_of :name
    validates_uniqueness_of :name


    has_many :categorizations
    has_many :products, :through => :categorizations, :dependent => :destroy


    def self.form_attributes
      [
    		{"product_ids" => {"type" => "has_many", "model" => "Adminpanel::Product", "name" => "product_ids"}},
    		{"name" => {"type" => "text_field", "name" => "name", "label" => "name", "placeholder" => "name"}},
      ]
    end

    def self.display_name
      "Categoría"
    end

    # def self.icon
    #     "icon-truck"
    # end

    default_scope { order("model ASC")}
    scope :of_model, lambda{|model| where(:model => model)}
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adminpanel-1.2.8 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-1.2.7 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-1.2.6 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-1.2.5 lib/generators/adminpanel/initialize/templates/category_template.rb