Sha256: 3712ddc0bfa8899f782b62df607476d0fae67b867d88127fdb1d2b511e7f5640

Contents?: true

Size: 1016 Bytes

Versions: 4

Compression:

Stored size: 1016 Bytes

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

	  has_many :images, :foreign_key => "foreign_key", :conditions => { :model => "Section" }
	  accepts_nested_attributes_for :images, :allow_destroy => true


	  validates_length_of :description, :minimum => 10, :maximum => 10, :on => :update, :if => lambda{|section| section.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 == "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 simple_name
	  	"Section"
	  end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adminpanel-1.2.5 app/models/adminpanel/section.rb
adminpanel-1.2.4 app/models/adminpanel/section.rb
adminpanel-1.2.3 app/models/adminpanel/section.rb
adminpanel-1.2.2 app/models/adminpanel/section.rb