mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-14 04:04:03 +00:00
Add flash type error.Rewrite controllers to use common flash style with redirect_to
This commit is contained in:
parent
dcdceb7c6d
commit
434eb90b76
16 changed files with 81 additions and 85 deletions
|
|
@ -6,22 +6,18 @@ class SubscriptionsController < ApplicationController
|
|||
def create
|
||||
@subscription = current_user.subscriptions.build(conference_id: @conference.id)
|
||||
if @subscription.save!
|
||||
flash[:notice] = "You have been subscribed to receive email notifications for #{@conference.short_title}."
|
||||
redirect_to root_path
|
||||
redirect_to root_path, notice: "You have been subscribed to receive email notifications for #{@conference.short_title}."
|
||||
else
|
||||
flash[:error] = subscription.errors.full_messages.to_sentence
|
||||
redirect_to root_path
|
||||
redirect_to root_path, error: subscription.errors.full_messages.to_sentence
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@subscription = current_user.subscriptions.find_by(conference_id: @conference.id)
|
||||
if @subscription.destroy
|
||||
flash[:notice] = "You have been unsubscribed and now you will not be receiving email notifications for #{@conference.short_title}."
|
||||
redirect_to root_path
|
||||
redirect_to root_path, notice: "You have been unsubscribed and now you will not be receiving email notifications for #{@conference.short_title}."
|
||||
else
|
||||
flash[:error] = @subscription.errors.full_messages.to_sentence
|
||||
redirect_to root_path
|
||||
redirect_to root_path, error: @subscription.errors.full_messages.to_sentence
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue