Allow updating the status of notifications
You can update the same "notifications" section that we allow you to update in "my account". This "subscriptions" section differs from the "my account" section because we do not need to be logged in to update the status of the notifications.
This commit is contained in:
@@ -5,6 +5,12 @@ class SubscriptionsController < ApplicationController
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@user.update!(subscriptions_params)
|
||||
redirect_to edit_subscriptions_path(token: @user.subscriptions_token),
|
||||
notice: t("flash.actions.save_changes.notice")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_user
|
||||
@@ -14,4 +20,12 @@ class SubscriptionsController < ApplicationController
|
||||
current_user || raise(CanCan::AccessDenied)
|
||||
end
|
||||
end
|
||||
|
||||
def subscriptions_params
|
||||
params.require(:user).permit(allowed_params)
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
[:email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user