0

The delete button I have in my rails app returns the following error :

No route matches [DELETE] "/requests.3"

I'm not sure why.

Here is the button link in the request view (using bootstrap 3) :

<%= link_to '<i class="glyphicon glyphicon-remove"></i>'.html_safe,
    requests_path(request), method: :delete,
    data: { confirm: 'Are you sure?' },  class: 'btn btn-danger' %>

and in routes I have :

delete 'requests/:id' => 'requests#destroy'

and in the controller I have

def destroy
  @request = Request.find(params[:id])
  @request.destroy
  redirect_to action: 'index', status: 303
end

Any help would be appreciated.

Thank you.

Avir94
  • 899
  • 9
  • 19
  • 1
    Possible duplicate of [Path helpers generate paths with dots instead of slashes](http://stackoverflow.com/questions/5674116/path-helpers-generate-paths-with-dots-instead-of-slashes) – Kieran E Jul 30 '16 at 01:55
  • Following that thread lead to changing `requests_path` to `request_path` which led to an `undefined method \`request_path\` ` error. @KieranE – Avir94 Aug 01 '16 at 15:58

1 Answers1

0

The solution I figured to work was to manually specify the path in the <%= link_to tag

<%= link_to '<i class="glyphicon glyphicon-remove"></i>'.html_safe,
"/requests/#{request.id}/destroy", method: :delete, 
data: { confirm: 'Are you sure?' },  class: 'btn btn-danger' %>

and that seemed to work.

Avir94
  • 899
  • 9
  • 19