title: Rails 4 destroy action, undefined_method message_path
body: <p>I have problem with Rails destroy action. I have fully working message system. User can send, read messages but can't delete it.
  My Message Controller is:</p>
  
  <pre><code>class MessagesController &lt; ApplicationController
   before_filter :set_user
   def index
     if params[:mailbox] == "sent"
      @messages = @user.sent_messages.page(params[:page])
     elsif params[:mailbox] == "inbox"
      @messages = @user.received_messages.page(params[:page])
     end
   end
  
   def new
    @message = Message.new
    @reply_to = User.find_by_id(params[:reply_to])
    unless @reply_to.nil?
      @message.recepient_id = @reply_to.id
    end
   end
  
   def create
    @message = Message.new(message_params)
    @message.sender_id = @user.id
    if @message.save
     flash[:notice] = "Message has been sent"
     redirect_to user_messages_path(current_user, :mailbox=&gt;:inbox)
    else
     render :action =&gt; :new
    end
   end
  
   def show
    @message = Message.readingmessage(params[:id],@user.id)
   end
   def destroy
    @message = Message.find(params[:id])
    @message.destroy
   end
  
  private
  
   def message_params
    params.require(:message).permit(:sender_id, :recepient_id, :body, :subject, :read_at)
   end
  
   def set_user
    @user = current_user
   end
  end
  </code></pre>
  
  <p>My Routes are:</p>
  
  <pre><code>resources :users do
    resources :messages 
  end
  </code></pre>
  
  <p>In view I have link to delete(which is not working):</p>
  
  <pre><code> %h2 Your Inbox
  - if @messages.size == 0
    %h1 No messages in your Inbox
  - else
    %table.table.table-bordered
      %tr
        %th Subject
        %th Sender
        %th Sent At
      - for message in @messages
        %tr
          %td
            - if message.read?
              = link_to h(message.subject), user_message_path(@user, message)
            - else
              = link_to "#{h(message.subject)} (unread)", user_message_path(@user, message)
          %td= "#{message.sender.name}"
          = link_to "Delete Message", @message, method: :delete, data: {confirm: "You sure?"}
  </code></pre>
  
  <p>When i Click this link i have following error:</p>
  
  <pre><code>No route matches [DELETE] 
  </code></pre>
  
  <p>rake routes for Messages:</p>
  
  <pre><code>         user_messages GET    /users/:user_id/messages(.:format)          messages#index
                         POST   /users/:user_id/messages(.:format)          messages#create
        new_user_message GET    /users/:user_id/messages/new(.:format)      messages#new
       edit_user_message GET    /users/:user_id/messages/:id/edit(.:format) messages#edit
            user_message GET    /users/:user_id/messages/:id(.:format)      messages#show
                         PATCH  /users/:user_id/messages/:id(.:format)      messages#update
                         PUT    /users/:user_id/messages/:id(.:format)      messages#update
                         DELETE /users/:user_id/messages/:id(.:format)      messages#destroy
  </code></pre>
  
  <p>Any ideas? :)</p>