Class: Decidim::FollowsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Decidim::FollowsController
- Includes:
- FormFactory
- Defined in:
- app/controllers/decidim/follows_controller.rb
Instance Method Summary collapse
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from RegistersPermissions
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/decidim/follows_controller.rb', line 25 def create @form = form(Decidim::FollowForm).from_params(params) @inline = params[:follow][:inline] == "true" :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: :unprocessable_entity end end end |
#destroy ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/decidim/follows_controller.rb', line 9 def destroy @form = form(Decidim::FollowForm).from_params(params) @inline = params[:follow][:inline] == "true" :delete, :follow, follow: @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: :unprocessable_entity end end end |
#resource ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/decidim/follows_controller.rb', line 41 def resource @resource ||= GlobalID::Locator.locate_signed( params[:follow][:followable_gid] ) end |