Sha256: 45819a899910bc885695c6c70fe295f61bcd5b45c39947987f30cf2a5d7e95af

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 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

    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

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.11.2 app/forms/decidim/follow_form.rb
decidim-core-0.11.1 app/forms/decidim/follow_form.rb
decidim-core-0.11.0.pre1 app/forms/decidim/follow_form.rb