Sha256: 9396d33743ea2f835eaae272ea452c2b10d82fa45f022704f73477e6595cd1fd

Contents?: true

Size: 749 Bytes

Versions: 4

Compression:

Stored size: 749 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ActionDelegator
    class Ponderation < ApplicationRecord
      self.table_name = "decidim_action_delegator_ponderations"

      belongs_to :setting,
                 foreign_key: "decidim_action_delegator_setting_id",
                 class_name: "Decidim::ActionDelegator::Setting"

      has_many :participants,
               foreign_key: "decidim_action_delegator_ponderation_id",
               class_name: "Decidim::ActionDelegator::Participant",
               dependent: :restrict_with_error

      delegate :consultation, to: :setting

      def title
        @title ||= "#{name} (x#{weight})"
      end

      def destroyable?
        participants.empty?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-action_delegator-0.8.1 app/models/decidim/action_delegator/ponderation.rb
decidim-action_delegator-0.7.2 app/models/decidim/action_delegator/ponderation.rb
decidim-action_delegator-0.7.1 app/models/decidim/action_delegator/ponderation.rb
decidim-action_delegator-0.7.0 app/models/decidim/action_delegator/ponderation.rb