Use resourceful destroy method for messages
This commit is contained in:
parent
6027c42ee7
commit
5405dde6ec
6 changed files with 12 additions and 13 deletions
|
@ -110,7 +110,7 @@ class MessagesController < ApplicationController
|
|||
|
||||
# Destroy the message.
|
||||
def destroy
|
||||
@message = Message.where("to_user_id = ? OR from_user_id = ?", current_user.id, current_user.id).find(params[:message_id])
|
||||
@message = Message.where("to_user_id = ? OR from_user_id = ?", current_user.id, current_user.id).find(params[:id])
|
||||
@message.from_user_visible = false if @message.sender == current_user
|
||||
@message.to_user_visible = false if @message.recipient == current_user
|
||||
if @message.save && !request.xhr?
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
<td class="inbox-sent"><%= l message_summary.sent_on, :format => :friendly %></td>
|
||||
<td class="inbox-mark-unread"><%= button_to t('.unread_button'), mark_message_path(message_summary, :mark => 'unread'), { :remote => true } %></td>
|
||||
<td class="inbox-mark-read"><%= button_to t('.read_button'), mark_message_path(message_summary, :mark => 'read'), { :remote => true } %></td>
|
||||
<td class="inbox-destroy"><%= button_to t('.destroy_button'), destroy_message_path(message_summary, :referer => request.fullpath), { :remote => true } %></td>
|
||||
<td class="inbox-destroy"><%= button_to t('.destroy_button'), message_path(message_summary, :referer => request.fullpath), { :method => :delete, :remote => true } %></td>
|
||||
</tr>
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
<td class="inbox-sender"><%= link_to h(sent_message_summary.recipient.display_name), user_path(sent_message_summary.recipient) %></td>
|
||||
<td class="inbox-subject"><%= link_to h(sent_message_summary.title), message_path(sent_message_summary) %></td>
|
||||
<td class="inbox-sent"><%= l sent_message_summary.sent_on, :format => :friendly %></td>
|
||||
<td class="inbox-destroy"><%= button_to t('.destroy_button'), destroy_message_path(sent_message_summary, :referer => request.fullpath), { :remote => true } %></td>
|
||||
<td class="inbox-destroy"><%= button_to t('.destroy_button'), message_path(sent_message_summary, :referer => request.fullpath), { :method => :delete, :remote => true } %></td>
|
||||
</tr>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div class='message-buttons buttons'>
|
||||
<%= button_to t('.reply_button'), reply_message_path(@message), :class => 'reply-button' %>
|
||||
<%= button_to t('.unread_button'), mark_message_path(@message, :mark => 'unread'), :class => 'mark-unread-button' %>
|
||||
<%= button_to t('.destroy_button'), destroy_message_path(@message), :class => 'destroy-button' %>
|
||||
<%= button_to t('.destroy_button'), message_path(@message), :method => 'delete', :class => 'destroy-button' %>
|
||||
|
||||
<% else %>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue