diff options
author | David Gay <david@davidgay.org> | 2021-06-06 17:57:43 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-06 17:57:43 -0400 |
commit | 3622126380278d9bed8ea0e1e05a0bd1ea040596 (patch) | |
tree | f34f85368138cc3038f362ac4c68a9d5756f55fc /app/controllers | |
parent | 387684c8be4691c4469677e48e1b0a46ad600363 (diff) |
Messages
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/messages_controller.rb | 19 |
1 files changed, 19 insertions, 0 deletions
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 |