Sha256: 6a0fc81439b747b0ec778a320e9b4f9f8690e327106ce029d17ef46b71462d49

Contents?: true

Size: 952 Bytes

Versions: 16

Compression:

Stored size: 952 Bytes

Contents

module Adminpanel
  class Category < ActiveRecord::Base
    include Adminpanel::Base

    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
      "Categoria" #singular
    end

    def self.icon
        "bookmark" #fa-{icon}
    end

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
adminpanel-2.4.3 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.4.2 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.4.1 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.4.0 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.3.1 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.3.0 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.2.5 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.2.4 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.2.3 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.2.2 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.2.1 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.2.0 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.1.7 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.1.6 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.1.5 lib/generators/adminpanel/initialize/templates/category_template.rb
adminpanel-2.1.3 lib/generators/adminpanel/initialize/templates/category_template.rb