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.15.0 app/forms/decidim/follow_form.rb
decidim-core-0.14.4 app/forms/decidim/follow_form.rb
decidim-core-0.14.3 app/forms/decidim/follow_form.rb
decidim-core-0.14.2 app/forms/decidim/follow_form.rb
decidim-core-0.14.1 app/forms/decidim/follow_form.rb
decidim-core-0.13.1 app/forms/decidim/follow_form.rb
decidim-core-0.12.2 app/forms/decidim/follow_form.rb
decidim-core-0.13.0 app/forms/decidim/follow_form.rb
decidim-core-0.12.1 app/forms/decidim/follow_form.rb
decidim-core-0.13.0.pre1 app/forms/decidim/follow_form.rb
decidim-core-0.12.0 app/forms/decidim/follow_form.rb
decidim-core-0.12.0.pre app/forms/decidim/follow_form.rb