Sha256: 0ff1e2229e6e8127dbe338d9fa7a580ae0c2fc7ec2f1492e5526e9eae3077fb9
Contents?: true
Size: 773 Bytes
Versions: 49
Compression:
Stored size: 773 Bytes
Contents
# frozen_string_literal: true module Decidim class Coauthorship < ApplicationRecord include Decidim::Authorable belongs_to :coauthorable, polymorphic: true, counter_cache: true validates :coauthorable, presence: 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
49 entries across 49 versions & 1 rubygems