Sha256: d20d2c044dba03ccb76743a38f2d74b6aa2db4cf16da20d2eb1e6a8db4f99c67

Contents?: true

Size: 845 Bytes

Versions: 14

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Consultations
    # The data store for question's votes in the Decidim::Consultations component.
    class Vote < ApplicationRecord
      include Authorable

      belongs_to :question,
                 foreign_key: "decidim_consultation_question_id",
                 class_name: "Decidim::Consultations::Question",
                 counter_cache: :votes_count,
                 inverse_of: :votes

      belongs_to :response,
                 foreign_key: "decidim_consultations_response_id",
                 class_name: "Decidim::Consultations::Response",
                 inverse_of: :votes,
                 counter_cache: :votes_count

      validates :author, uniqueness: { scope: [:decidim_user_group_id, :question] }

      delegate :organization, to: :question
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-consultations-0.14.4 app/models/decidim/consultations/vote.rb
decidim-consultations-0.14.3 app/models/decidim/consultations/vote.rb
decidim-consultations-0.14.2 app/models/decidim/consultations/vote.rb
decidim-consultations-0.14.1 app/models/decidim/consultations/vote.rb
decidim-consultations-0.13.1 app/models/decidim/consultations/vote.rb
decidim-consultations-0.12.2 app/models/decidim/consultations/vote.rb
decidim-consultations-0.13.0 app/models/decidim/consultations/vote.rb
decidim-consultations-0.12.1 app/models/decidim/consultations/vote.rb
decidim-consultations-0.13.0.pre1 app/models/decidim/consultations/vote.rb
decidim-consultations-0.12.0 app/models/decidim/consultations/vote.rb
decidim-consultations-0.11.2 app/models/decidim/consultations/vote.rb
decidim-consultations-0.12.0.pre app/models/decidim/consultations/vote.rb
decidim-consultations-0.11.1 app/models/decidim/consultations/vote.rb
decidim-consultations-0.11.0.pre1 app/models/decidim/consultations/vote.rb