所以我正在尝试建立一个基本的客户端分配系统,但我遇到了一个问题。
这些是我想要的路径:
assign POST /assign
unassign DELETE /unassign/:id
但我从rake routes
获得以下内容:
assign POST /assign
DELETE /unassign/:id
有趣的是,当我输出链接时,URL看起来像这样:
http://localhost:3000/assign.1
为什么不使用/
?此外,如何制作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'}
我想使用unassign_path
,而不是assign_path
..我做错了什么?
答案 0 :(得分:2)
请改为尝试:
delete '/unassign/:id', to: 'clients#unassign', as: :unassign
答案 1 :(得分:1)
将以下行添加到routes.rb
match '/assign' => 'clients#assign_to', :via => :post, :as => "assign"
match '/unassign/:id' => 'clients#unassign', :via => :delete, :as => "unassign"