Sha256: db8b0fa23b8c4300f0404513a7e0e74576535f0e07d6deb02ffb1f467bc913a1
Contents?: true
Size: 1.06 KB
Versions: 37
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Decidim class FollowsController < Decidim::ApplicationController include FormFactory before_action :authenticate_user! helper_method :resource def destroy @form = form(Decidim::FollowForm).from_params(params) authorize! :delete, @form.follow DeleteFollow.call(@form, current_user) do on(:ok) do render :update_button end on(:invalid) do render json: { error: I18n.t("follows.destroy.error", scope: "decidim") }, status: 422 end end end def create @form = form(Decidim::FollowForm).from_params(params) authorize! :create, Follow CreateFollow.call(@form, current_user) do on(:ok) do render :update_button end on(:invalid) do render json: { error: I18n.t("follows.create.error", scope: "decidim") }, status: 422 end end end def resource @resource ||= GlobalID::Locator.locate_signed( params[:follow][:followable_gid] ) end end end
Version data entries
37 entries across 37 versions & 2 rubygems