Sha256: cd490d2a4ba482f47be12c8d0fcabeff35f85af67c925983d0980340bf370f92

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'carrierwave'
require 'carrierwave/orm/activerecord'
module Adminpanel
	class Section < ActiveRecord::Base
	  attr_accessible :description, :has_image, :key, :page, :name, :has_description,
		:images_attributes, :file

	  mount_images :images

	  validates_length_of :description, :minimum => 10, :maximum => 10, :on => :update, :if => lambda{|section| section.key == I18n.t('key.telephone')}
	  validates_presence_of :description, :minimum => 9, :on => :update, :if => lambda{|section| section.has_description == true}
	  validates :description, :numericality => { :only_integer => true }, :on => :update, :if => lambda{|section| section.key == I18n.t('key.telephone')}
	  validates_presence_of :key
	  validates_presence_of :name
	  validates_presence_of :page

	  default_scope { order("page ASC")}

	  scope :of_page, lambda{|page| where(:page => page)}

		def self.form_methods
			[
				{'description' => {'name' => 'Descripcion'}},
				{'name' => {'name' => 'name'}},
				{'key' => {'name' => 'key'}},
				{'page' => {'name' => 'page'}},
				# {'key' => {'name' => 'key'}},
			]

		end

	  def self.icon
	  	"icon-tasks"
	  end

		def self.display_name
			'Secciones'
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adminpanel-1.2.12 app/models/adminpanel/section.rb
adminpanel-1.2.11 app/models/adminpanel/section.rb
adminpanel-1.2.10 app/models/adminpanel/section.rb
adminpanel-1.2.9 app/models/adminpanel/section.rb