Sha256: df527a6af7a2735ae3e04d32943f282d62f86bc917750ec5ccea10d8c727d28a

Contents?: true

Size: 708 Bytes

Versions: 24

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    # The data store for a LineItem in the Decidim::Budgets component. It describes an
    # association between an order and a project.
    class LineItem < Budgets::ApplicationRecord
      belongs_to :order, class_name: "Decidim::Budgets::Order", foreign_key: "decidim_order_id"
      belongs_to :project, class_name: "Decidim::Budgets::Project", foreign_key: "decidim_project_id"

      validates :order, uniqueness: { scope: :project }
      validate :same_component

      def same_component
        return unless order && project
        errors.add(:order, :invalid) unless order.component == project.component
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-budgets-0.18.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.17.2 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.18.0 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.17.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.16.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.17.0 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.16.0 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.15.2 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.15.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.15.0 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.14.4 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.14.3 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.14.2 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.14.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.13.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.12.2 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.13.0 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.12.1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.13.0.pre1 app/models/decidim/budgets/line_item.rb
decidim-budgets-0.12.0 app/models/decidim/budgets/line_item.rb