Class: Decidim::UserInterestsController

Inherits:
ApplicationController show all
Includes:
UserProfile
Defined in:
app/controllers/decidim/user_interests_controller.rb

Overview

The controller to handle the user’s interests page.

Instance Method Summary collapse

Methods included from UserProfile

#available_verification_workflows

Methods included from UserGroups

#enforce_user_groups_enabled

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#showObject



10
11
12
13
# File 'app/controllers/decidim/user_interests_controller.rb', line 10

def show
  enforce_permission_to :read, :user, current_user: current_user
  @user_interests = form(UserInterestsForm).from_model(current_user)
end

#updateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/decidim/user_interests_controller.rb', line 15

def update
  enforce_permission_to :update, :user, current_user: current_user
  @user_interests = form(UserInterestsForm).from_params(params)

  UpdateUserInterests.call(current_user, @user_interests) do
    on(:ok) do
      flash.keep[:notice] = t("user_interests.update.success", scope: "decidim")
    end

    on(:invalid) do
      flash.keep[:alert] = t("user_interests.update.error", scope: "decidim")
    end
  end

  redirect_to action: :show
end