Sha256: 54eba0c1c54a66b016f209ac7f36ad819f43a70fb40c45cd86e97ec30b5c6a66
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
# encoding: utf-8 module ConstructorPages # Template model. Template allows assing different design for pages. # # Templates has many fields. # For example: # template "Product" should has fields like "price", "description", "size" etc. class Template < ActiveRecord::Base # Adding code_name_uniqueness method include CodeNameUniq validates_presence_of :name, :code_name validates_uniqueness_of :code_name validate :code_name_uniqueness default_scope -> { order :lft } has_many :pages, dependent: :destroy has_many :fields, dependent: :destroy acts_as_nested_set # Return child corresponding child_id or children first def child child_id ? self.class.find(child_id) : children.first if !leaf? end # Convert name to accusative def to_accusative self.name.mb_chars.downcase.to_s.accusative end private # Check if there is code_name in same branch def check_code_name(cname) [cname.pluralize, cname.singularize].each {|name| return false if root.descendants.map{|t| t.code_name unless t.code_name == cname}.include?(name)} true end end end
Version data entries
6 entries across 6 versions & 1 rubygems