From f25d4dbf8cedfde011fc049dfb3fc6692c543cf4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Feb 2017 21:10:20 +1300 Subject: [PATCH] DRY for the notifications controller --- app/controllers/notifications_controller.rb | 32 ++++----------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 03b0ef8f8..431f80d7d 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -2,14 +2,11 @@ class NotificationsController < ApplicationController include NotificationsHelper before_action :authenticate_member! load_and_authorize_resource + respond_to :html # GET /notifications def index @notifications = Notification.by_recipient(current_member).page(params[:page]) - - respond_to do |format| - format.html # index.html.erb - end end # GET /notifications/1 @@ -17,10 +14,6 @@ class NotificationsController < ApplicationController @notification.read = true @notification.save @reply_link = reply_link(@notification) - - respond_to do |format| - format.html # show.html.erb - end end # GET /notifications/new @@ -29,10 +22,6 @@ class NotificationsController < ApplicationController @notification = Notification.new @recipient = Member.find_by(id: params[:recipient_id]) @subject = params[:subject] || "" - - respond_to do |format| - format.html # new.html.erb - end end # GET /notifications/1/reply @@ -45,19 +34,12 @@ class NotificationsController < ApplicationController @subject = @sender_notification.subject =~ /^Re: / ? @sender_notification.subject : "Re: " + @sender_notification.subject - - respond_to do |format| - format.html # reply.html.haml - end end # DELETE /notifications/1 def destroy @notification.destroy - - respond_to do |format| - format.html { redirect_to notifications_url } - end + redirect_to notifications_url end # POST /notifications @@ -66,12 +48,10 @@ class NotificationsController < ApplicationController @notification = Notification.new(notification_params) @recipient = Member.find_by(id: params[:notification][:recipient_id]) - respond_to do |format| - if @notification.save - format.html { redirect_to notifications_path, notice: 'Message was successfully sent.' } - else - format.html { render action: "new" } - end + if @notification.save + redirect_to notifications_path, notice: 'Message was successfully sent.' + else + render action: "new" end end