diff options
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 |