Class: Profiles::NotificationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/profiles/notifications_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject


2
3
4
5
6
# File 'app/controllers/profiles/notifications_controller.rb', line 2

def show
  @user = current_user
  @group_notifications = current_user.notification_settings.for_groups
  @project_notifications = current_user.notification_settings.for_projects
end

#updateObject


8
9
10
11
12
13
14
15
16
# File 'app/controllers/profiles/notifications_controller.rb', line 8

def update
  if current_user.update_attributes(user_params)
    flash[:notice] = "Notification settings saved"
  else
    flash[:alert] = "Failed to save new settings"
  end

  redirect_back_or_default(default: profile_notifications_path)
end

#user_paramsObject


18
19
20
# File 'app/controllers/profiles/notifications_controller.rb', line 18

def user_params
  params.require(:user).permit(:notification_email, :notification_level)
end