Sha256: 69e6cee0c78931c5b86d26b398de807616cfa539e8ef1e28fb5e5757c6e78002

Contents?: true

Size: 1.12 KB

Versions: 14

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    # The data store for an Answer in the Decidim::Elections component. It stores a
    # title, description and related resources and attachments.
    class Answer < ApplicationRecord
      include Decidim::Resourceable
      include Decidim::HasAttachments
      include Decidim::HasAttachmentCollections
      include Traceable
      include Loggable

      delegate :organization, :participatory_space, to: :component

      belongs_to :question, foreign_key: "decidim_elections_question_id", class_name: "Decidim::Elections::Question", inverse_of: :answers
      has_one :election, through: :question, foreign_key: "decidim_elections_election_id", class_name: "Decidim::Elections::Election"
      has_one :component, through: :election, foreign_key: "decidim_component_id", class_name: "Decidim::Component"

      default_scope { order(weight: :asc, id: :asc) }

      # Public: Get all the proposals related to the answer
      #
      # Returns an ActiveRecord::Relation.
      def proposals
        linked_resources(:proposals, "related_proposals")
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-elections-0.24.3 app/models/decidim/elections/answer.rb
decidim-elections-0.23.6 app/models/decidim/elections/answer.rb
decidim-elections-0.24.2 app/models/decidim/elections/answer.rb
decidim-elections-0.23.5 app/models/decidim/elections/answer.rb
decidim-elections-0.24.1 app/models/decidim/elections/answer.rb
decidim-elections-0.24.0 app/models/decidim/elections/answer.rb
decidim-elections-0.24.0.rc2 app/models/decidim/elections/answer.rb
decidim-elections-0.23.4 app/models/decidim/elections/answer.rb
decidim-elections-0.24.0.rc1 app/models/decidim/elections/answer.rb
decidim-elections-0.23.3 app/models/decidim/elections/answer.rb
decidim-elections-0.23.2 app/models/decidim/elections/answer.rb
decidim-elections-0.23.1 app/models/decidim/elections/answer.rb
decidim-elections-0.23.1.rc1 app/models/decidim/elections/answer.rb
decidim-elections-0.23.0 app/models/decidim/elections/answer.rb