Sha256: 415f4126bd150763b4b70e5d804148d04ae5b5472046845ec4b03ad57b8c0153

Contents?: true

Size: 656 Bytes

Versions: 16

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This concern contains the logic related to followable resources.
  module Followable
    extend ActiveSupport::Concern

    included do
      has_many :follows, as: :followable, foreign_key: "decidim_followable_id", foreign_type: "decidim_followable_type", class_name: "Decidim::Follow"
      has_many :followers, through: :follows, source: :user
    end

    def followers
      if respond_to?(:participatory_space) && participatory_space.present? && participatory_space.respond_to?(:followers)
        super.or(participatory_space.followers).distinct
      else
        super
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-core-0.23.6 lib/decidim/followable.rb
decidim-core-0.23.5 lib/decidim/followable.rb
decidim-core-0.24.0.rc2 lib/decidim/followable.rb
decidim-core-0.23.4 lib/decidim/followable.rb
decidim-core-0.24.0.rc1 lib/decidim/followable.rb
decidim-core-0.23.3 lib/decidim/followable.rb
decidim-core-0.23.2 lib/decidim/followable.rb
decidim-core-0.23.1 lib/decidim/followable.rb
decidim-core-0.23.1.rc1 lib/decidim/followable.rb
decidim-core-0.23.0 lib/decidim/followable.rb
decidim-core-0.22.0 lib/decidim/followable.rb
decidim-core-0.21.0 lib/decidim/followable.rb
decidim-core-0.20.1 lib/decidim/followable.rb
decidim-core-0.20.0 lib/decidim/followable.rb
decidim-core-0.19.1 lib/decidim/followable.rb
decidim-core-0.19.0 lib/decidim/followable.rb