Sha256: f192a93e020be1484c31bdddc4a7c23ee4413c9a69d9dcc4eaa2038c30ca874f
Contents?: true
Size: 787 Bytes
Versions: 24
Compression:
Stored size: 787 Bytes
Contents
# frozen_string_literal: true module Decidim module Proposals # A proposal can include a vote per user. class ProposalVote < ApplicationRecord belongs_to :proposal, foreign_key: "decidim_proposal_id", class_name: "Decidim::Proposals::Proposal", counter_cache: true belongs_to :author, foreign_key: "decidim_author_id", class_name: "Decidim::User" validates :proposal, uniqueness: { scope: :author } validate :author_and_proposal_same_organization private # Private: check if the proposal and the author have the same organization def author_and_proposal_same_organization return if !proposal || !author errors.add(:proposal, :invalid) unless author.organization == proposal.organization end end end end
Version data entries
24 entries across 24 versions & 2 rubygems