class NotificationSettingsController

Public Instance Methods

create_or_update() click to toggle source

To update notification setting of user.(i.e. manage notifications in user settings)

# File app/controllers/notification_settings_controller.rb, line 6
def create_or_update
  respond_to do |format|
    @user_notification_type = current_user.notification_settings.find_or_initialize_by(notification_type: params[:notification_setting][:notification_type])
    @user_notification_type.enabled = params[:notification_setting][:enabled]
    if @user_notification_type.save
      @message = 'Notification Type Updated successfully.'
      format.js
    else
      @message = 'Notification Type Not Updated.'
      format.js
    end
  end
end