[英]Route using dot rather than / in rails DELETE method
The delete button I have in my rails app returns the following error : 我在Rails应用程序中拥有的Delete按钮返回以下错误:
No route matches [DELETE] "/requests.3"
I'm not sure why. 我不知道为什么。
Here is the button link in the request view (using bootstrap 3) : 这是请求视图中的按钮链接(使用引导程序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. 谢谢。
The solution I figured to work was to manually specify the path in the <%= link_to
tag 我想到的解决方案是在
<%= link_to
标记中手动指定路径
<%= 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. 这似乎可行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.