Sha256: a138cd7d736722edaf2412b69683c2c27d4976219aefa8f4d77ab0569440f156
Contents?: true
Size: 766 Bytes
Versions: 9
Compression:
Stored size: 766 Bytes
Contents
# encoding: utf-8 module ConstructorPages class Template < ActiveRecord::Base attr_accessible :name, :code_name, :child_id, :parent_id validates_presence_of :name validates_uniqueness_of :code_name validate :method_uniqueness default_scope order(:lft) has_many :pages has_many :fields acts_as_nested_set private def method_uniqueness if Page.first.respond_to?(code_name.pluralize) \ or Page.first.respond_to?(code_name.singularize) \ or root.descendants.map{|t| t.code_name}.include?(code_name.pluralize) \ or root.descendants.map{|t| t.code_name}.include?(code_name.singularize) \ errors.add(:base, "Такой метод уже используется") end end end end
Version data entries
9 entries across 9 versions & 1 rubygems