Sha256: a453a4d6d857b8271a275b850d244489d9a06918461413f8148f3e4669b83391

Contents?: true

Size: 787 Bytes

Versions: 9

Compression:

Stored size: 787 Bytes

Contents

module Georgia
  class UiAssociation < ActiveRecord::Base

    include Georgia::Concerns::Orderable
    acts_as_list scope: :page

    belongs_to :revision, class_name: Georgia::Revision, foreign_key: :page_id
    belongs_to :widget
    belongs_to :ui_section

    attr_accessible :position, :widget_id, :ui_section_id, :page_id

    scope :for_revision, lambda {|revision| where(page_id: revision.id)}

    validate :associations

    protected

    # Validations
    def associations
      errors.add(:base, "An association to a page is required.") unless page_id.present?
      errors.add(:base, "An association to a UI Section is required.") unless ui_section_id.present?
      errors.add(:base, "An association to a Widget is required.") unless widget_id.present?
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
georgia-0.7.8 app/models/georgia/ui_association.rb
georgia-0.7.7 app/models/georgia/ui_association.rb
georgia-0.7.6 app/models/georgia/ui_association.rb
georgia-0.7.5 app/models/georgia/ui_association.rb
georgia-0.7.4 app/models/georgia/ui_association.rb
georgia-0.7.3 app/models/georgia/ui_association.rb
georgia-0.7.2 app/models/georgia/ui_association.rb
georgia-0.7.1 app/models/georgia/ui_association.rb
georgia-0.7.0 app/models/georgia/ui_association.rb