Sha256: 7a7669927ee7746d85050ff1917bf9c3276f09482f1cdc2cd03ffb3d3d328c1e

Contents?: true

Size: 471 Bytes

Versions: 88

Compression:

Stored size: 471 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class ParticipatorySpaceLink < ApplicationRecord
    belongs_to :from, polymorphic: true
    belongs_to :to, polymorphic: true

    validates :name, presence: true, uniqueness: { scope: [:from, :to] }
    validate :same_organization

    private

    def same_organization
      return if from.try(:organization) == to.try(:organization)

      errors.add(:from, :invalid)
      errors.add(:to, :invalid)
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/models/decidim/participatory_space_link.rb
decidim-core-0.28.4 app/models/decidim/participatory_space_link.rb
decidim-core-0.27.9 app/models/decidim/participatory_space_link.rb
decidim-core-0.29.0 app/models/decidim/participatory_space_link.rb
decidim-core-0.28.3 app/models/decidim/participatory_space_link.rb
decidim-core-0.27.8 app/models/decidim/participatory_space_link.rb
decidim-core-0.29.0.rc4 app/models/decidim/participatory_space_link.rb
decidim-core-0.29.0.rc3 app/models/decidim/participatory_space_link.rb
decidim-core-0.29.0.rc2 app/models/decidim/participatory_space_link.rb
decidim-core-0.29.0.rc1 app/models/decidim/participatory_space_link.rb
decidim-core-0.28.2 app/models/decidim/participatory_space_link.rb
decidim-core-0.27.7 app/models/decidim/participatory_space_link.rb
decidim-core-0.28.1 app/models/decidim/participatory_space_link.rb
decidim-core-0.27.6 app/models/decidim/participatory_space_link.rb
decidim-core-0.26.10 app/models/decidim/participatory_space_link.rb
decidim-core-0.26.9 app/models/decidim/participatory_space_link.rb
decidim-core-0.28.0 app/models/decidim/participatory_space_link.rb
decidim-core-0.27.5 app/models/decidim/participatory_space_link.rb
decidim-core-0.28.0.rc5 app/models/decidim/participatory_space_link.rb
decidim-core-0.28.0.rc4 app/models/decidim/participatory_space_link.rb