Class: Decidim::FollowsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Decidim::FollowsController
- Includes:
- FormFactory
- Defined in:
- app/controllers/decidim/follows_controller.rb
Instance Method Summary collapse
- #button_cell ⇒ Object
- #button_cell_mobile ⇒ Object
- #button_options ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #resource ⇒ Object
Instance Method Details
#button_cell ⇒ Object
54 55 56 |
# File 'app/controllers/decidim/follows_controller.rb', line 54 def @button_cell ||= cell("decidim/follow_button", resource, **) end |
#button_cell_mobile ⇒ Object
50 51 52 |
# File 'app/controllers/decidim/follows_controller.rb', line 50 def @button_cell_mobile ||= cell("decidim/follow_button", resource, **, mobile: true) end |
#button_options ⇒ Object
46 47 48 |
# File 'app/controllers/decidim/follows_controller.rb', line 46 def params.expect(follow: [:button_classes]).to_h.symbolize_keys end |
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/decidim/follows_controller.rb', line 25 def create @form = form(Decidim::FollowForm).from_params(params) :create, :follow CreateFollow.call(@form) do on(:ok) do render :update_button end on(:invalid) do render json: { error: I18n.t("follows.create.error", scope: "decidim") }, status: :unprocessable_content end end end |
#destroy ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/decidim/follows_controller.rb', line 10 def destroy @form = form(Decidim::FollowForm).from_params(params) :delete, :follow, follow: @form.follow DeleteFollow.call(@form) do on(:ok) do render :update_button end on(:invalid) do render json: { error: I18n.t("follows.destroy.error", scope: "decidim") }, status: :unprocessable_content end end end |
#resource ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/decidim/follows_controller.rb', line 40 def resource @resource ||= GlobalID::Locator.locate_signed( params[:follow][:followable_gid] ) end |