Class: Decidim::FollowsController
Instance Method Summary
collapse
#check_user_block_status, #check_user_not_blocked
#snippets
#disable_http_caching
#skip_store_location?, #store_current_location
#default_locale?
register_permissions
enhance_controller, extended, included
Instance Method Details
53
54
55
|
# File 'app/controllers/decidim/follows_controller.rb', line 53
def button_cell
@button_cell ||= cell("decidim/follow_button", resource, **button_options)
end
|
49
50
51
|
# File 'app/controllers/decidim/follows_controller.rb', line 49
def button_cell_mobile
@button_cell_mobile ||= cell("decidim/follow_button", resource, **button_options.merge(mobile: true))
end
|
45
46
47
|
# File 'app/controllers/decidim/follows_controller.rb', line 45
def button_options
params.require(:follow).permit(:button_classes).to_h.symbolize_keys
end
|
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/decidim/follows_controller.rb', line 24
def create
@form = form(Decidim::FollowForm).from_params(params)
enforce_permission_to :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_entity
end
end
end
|
#destroy ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/decidim/follows_controller.rb', line 9
def destroy
@form = form(Decidim::FollowForm).from_params(params)
enforce_permission_to :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_entity
end
end
end
|
#resource ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/decidim/follows_controller.rb', line 39
def resource
@resource ||= GlobalID::Locator.locate_signed(
params[:follow][:followable_gid]
)
end
|