Sha256: 397dc86f31bbab2d27011a72f3b7d9c33954ddff8770a7a4f304f8d37872daa7
Contents?: true
Size: 856 Bytes
Versions: 25
Compression:
Stored size: 856 Bytes
Contents
# frozen_string_literal: true module Decidim # Store user's social identities class Identity < ApplicationRecord include Decidim::DownloadYourData belongs_to :user, foreign_key: :decidim_user_id, class_name: "Decidim::User" belongs_to :organization, foreign_key: :decidim_organization_id, class_name: "Decidim::Organization" validates :provider, presence: true validates :uid, presence: true, uniqueness: { scope: [:provider, :organization] } validate :same_organization def self.user_collection(user) where(decidim_user_id: user.id) end def self.export_serializer Decidim::DownloadYourDataSerializers::DownloadYourDataIdentitySerializer end private def same_organization return if organization == user&.organization errors.add(:organization, :invalid) end end end
Version data entries
25 entries across 25 versions & 1 rubygems