Sha256: 109ff7d9f5459c229e894f36cd51d03d3908594e690b61ad7f9e0d1d187887b4

Contents?: true

Size: 572 Bytes

Versions: 72

Compression:

Stored size: 572 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A form object to be used when users want to follow a followable resource.
  class FollowForm < Decidim::Form
    mimic :follow

    attribute :followable_gid, String

    validates :followable_gid, :followable, presence: true
    validates :followable, exclusion: { in: ->(form) { [form.current_user] } }

    def followable
      @followable ||= GlobalID::Locator.locate_signed followable_gid
    end

    def follow
      @follow ||= Decidim::Follow.find_by(user: current_user, followable: followable)
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/forms/decidim/follow_form.rb
decidim-core-0.27.8 app/forms/decidim/follow_form.rb
decidim-core-0.27.7 app/forms/decidim/follow_form.rb
decidim-core-0.27.6 app/forms/decidim/follow_form.rb
decidim-core-0.26.10 app/forms/decidim/follow_form.rb
decidim-core-0.26.9 app/forms/decidim/follow_form.rb
decidim-core-0.27.5 app/forms/decidim/follow_form.rb
decidim-core-0.26.8 app/forms/decidim/follow_form.rb
decidim-core-0.27.4 app/forms/decidim/follow_form.rb
decidim-core-0.27.3 app/forms/decidim/follow_form.rb
decidim-core-0.26.7 app/forms/decidim/follow_form.rb
decidim-core-0.26.5 app/forms/decidim/follow_form.rb
decidim-core-0.27.2 app/forms/decidim/follow_form.rb
decidim-core-0.27.1 app/forms/decidim/follow_form.rb
decidim-core-0.26.4 app/forms/decidim/follow_form.rb
decidim-core-0.27.0 app/forms/decidim/follow_form.rb
decidim-core-0.26.3 app/forms/decidim/follow_form.rb
decidim-core-0.27.0.rc2 app/forms/decidim/follow_form.rb
decidim-core-0.27.0.rc1 app/forms/decidim/follow_form.rb
decidim-core-0.26.2 app/forms/decidim/follow_form.rb