Sha256: 38f69e99be8022a6f0016598cf83f13a8b4d9c513a68adf49976b8e129ba1d59

Contents?: true

Size: 721 Bytes

Versions: 1

Compression:

Stored size: 721 Bytes

Contents

module Georgia
  class UiAssociation < ActiveRecord::Base

    # acts_as_list scope: :page

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

    scope :for_revision, -> (revision) { where(page_id: revision.id) }
    scope :ordered, -> { order(:position) }

    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

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.8.0 app/models/georgia/ui_association.rb