Sha256: e77bb45b261c60e39c9122bb8d496a91f0c93b9d99ebf2b5b936662b6f2a02c5
Contents?: true
Size: 728 Bytes
Versions: 12
Compression:
Stored size: 728 Bytes
Contents
# frozen_string_literal: true module Decidim class Coauthorship < ApplicationRecord include Decidim::Authorable belongs_to :coauthorable, polymorphic: true, counter_cache: true after_commit :author_is_follower, on: [:create] def identity user_group || author end private # As it is used to validate by comparing to author.organization # @returns The Organization for the Coauthorable def organization coauthorable&.organization end def author_is_follower return unless author.is_a?(Decidim::User) return unless coauthorable.is_a?(Decidim::Followable) Decidim::Follow.find_or_create_by!(followable: coauthorable, user: author) end end end
Version data entries
12 entries across 12 versions & 1 rubygems