[英]Rails route path
So i'm trying to set up a basic client assignment system, but I'm running into an issue. 因此,我正在尝试建立基本的客户端分配系统,但遇到了问题。
These are the paths I want: 这些是我想要的路径:
assign POST /assign
unassign DELETE /unassign/:id
but I am getting the following from rake routes
: 但是我从
rake routes
得到了以下信息:
assign POST /assign
DELETE /unassign/:id
The interesting thing is, when I output my link, the URL looks like this: 有趣的是,当我输出链接时,URL如下所示:
http://localhost:3000/assign.1
Why isn't using a /
? 为什么不使用
/
? Furthermore, how do I make it unassign DELETE /unassign/:id
? 此外,如何使它
unassign DELETE /unassign/:id
?
post '/assign' , to: 'clients#assign_to'
delete '/unassign/:id', to: 'clients#unassign'
= link_to assign_path(client.id), method: :delete, title: 'Unassign' do
%img{src: '/assets/unassign.png'}
I want to use unassign_path
, not assign_path
.. What am I doing wrong? 我想使用
unassign_path
,而不是assign_path
..我在做什么错?
尝试以下方法:
delete '/unassign/:id', to: 'clients#unassign', as: :unassign
Add the following lines to the beginning of your routes.rb
routes.rb
添加到routes.rb
的开头
match '/assign' => 'clients#assign_to', :via => :post, :as => "assign"
match '/unassign/:id' => 'clients#unassign', :via => :delete, :as => "unassign"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.