Try this instead:
delete '/unassign/:id', to: 'clients#unassign', as: :unassign
Pergunta
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
:
assign POST /assign
DELETE /unassign/:id
The interesting thing is, when I output my link, the URL looks like this:
http://localhost:3000/assign.1
Why isn't using a /
? Furthermore, how do I make it 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?
Solução
Try this instead:
delete '/unassign/:id', to: 'clients#unassign', as: :unassign
Outras dicas
Add the following lines to the beginning of your routes.rb
match '/assign' => 'clients#assign_to', :via => :post, :as => "assign"
match '/unassign/:id' => 'clients#unassign', :via => :delete, :as => "unassign"