Class: Decidim::LikesController
- Inherits:
-
Components::BaseController
- Object
- Components::BaseController
- Decidim::LikesController
- Includes:
- LikeableHelper
- Defined in:
- app/controllers/decidim/likes_controller.rb
Overview
Exposes the Likes so that users can like resources.
Instance Method Summary collapse
- #create ⇒ Object
-
#current_component ⇒ Object
should be pubic in order to be visible in NeedsPermission#permissions_context.
- #destroy ⇒ Object
Methods included from LikeableHelper
#current_user_can_like?, #likes_blocked?, #likes_enabled?, #path_to_create_like, #path_to_destroy_like, #show_likes_card?
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/decidim/likes_controller.rb', line 16 def create (:create, :like, resource:) LikeResource.call(resource, current_user) do on(:ok) do resource.reload render :update_buttons_and_counters end on(:invalid) do render json: { error: I18n.t("resource_likes.create.error", scope: "decidim") }, status: :unprocessable_content end end end |
#current_component ⇒ Object
should be pubic in order to be visible in NeedsPermission#permissions_context
43 44 45 |
# File 'app/controllers/decidim/likes_controller.rb', line 43 def current_component resource.component end |
#destroy ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/decidim/likes_controller.rb', line 31 def destroy (:withdraw, :like, resource:) UnlikeResource.call(resource, current_user) do on(:ok) do resource.reload render :update_buttons_and_counters end end end |