Sha256: a8c895462e904a497a6687b065e98d393dbcf376a52c6f3e90f1c02a57020485

Contents?: true

Size: 722 Bytes

Versions: 6

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ReportingProposals
    class CategoryValuator < ApplicationRecord
      self.table_name = "decidim_reporting_proposals_category_valuators"

      belongs_to :category,
                 foreign_key: "decidim_category_id",
                 class_name: "Decidim::Category"

      belongs_to :valuator_role,
                 polymorphic: true

      delegate :user, to: :valuator_role

      validate :category_belongs_to_same_participatory_space

      private

      def category_belongs_to_same_participatory_space
        return if category.participatory_space == valuator_role.participatory_space

        errors.add(:category, :invalid)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-reporting_proposals-0.6.0 app/models/decidim/reporting_proposals/category_valuator.rb
decidim-reporting_proposals-0.5.2 app/models/decidim/reporting_proposals/category_valuator.rb
decidim-reporting_proposals-0.5.1 app/models/decidim/reporting_proposals/category_valuator.rb
decidim-reporting_proposals-0.5.0 app/models/decidim/reporting_proposals/category_valuator.rb
decidim-reporting_proposals-0.4.2 app/models/decidim/reporting_proposals/category_valuator.rb
decidim-reporting_proposals-0.2.0 app/models/decidim/reporting_proposals/category_valuator.rb