Sha256: 649fd5b03f3dcaa0da225eb6b7c9efbc91cfa1c5427c79c83454ccef6f1a42f9
Contents?: true
Size: 1.63 KB
Versions: 23
Compression:
Stored size: 1.63 KB
Contents
=begin Camaleon CMS is a content management system Copyright (C) 2015 by Owen Peredo Diaz Email: owenperedo@gmail.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License (GPLv3) for more details. =end class CustomField < ActiveRecord::Base include Metas has_many :metas, ->{ where(object_class: 'CustomField')}, :class_name => "Meta", foreign_key: :objectid, dependent: :destroy self.table_name = "custom_fields" default_scope {order("custom_fields.field_order ASC")} # status: nil -> visible on list group fields attr_accessible :object_class, :objectid, :description, :parent_id, :count, :name, :slug, :field_order, :status, :is_repeat validates :name, :object_class, presence: true has_many :values, :class_name => "CustomFieldsRelationship", :foreign_key => :custom_field_id, dependent: :destroy belongs_to :custom_field_group, class_name: "CustomFieldGroup" belongs_to :parent, class_name: "CustomField", :foreign_key => :parent_id scope :configuration, -> {where(parent_id: -1)} scope :visible_group, -> {where(status: nil)} before_validation :before_validating private def before_validating self.slug = self.name if self.slug.blank? self.slug = self.slug.to_s.parameterize end end
Version data entries
23 entries across 23 versions & 1 rubygems