From 3622126380278d9bed8ea0e1e05a0bd1ea040596 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 6 Jun 2021 17:57:43 -0400 Subject: Messages --- app/controllers/messages_controller.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/controllers/messages_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb new file mode 100644 index 0000000..fdde395 --- /dev/null +++ b/app/controllers/messages_controller.rb @@ -0,0 +1,19 @@ +class MessagesController < ApplicationController + def index + @messages = Message.where(recipient: current_char).order(created_at: :desc) + end + + def destroy + @message = Message.find(params[:id]) + if @message.recipient == current_char + if @message.destroy + flash[:notice] = "Deleted message." + else + flash[:alert] = "Failed to delete message. Please report this bug." + end + else + flash[:alert] = "You can't delete someone else's message." + end + redirect_to messages_path + end +end -- cgit v1.2.3