Issue with routing

Hi everyone. I’m newbe in ROR and recently faced with a routing problem.
Here’s my route:

post ‘:type/delete/:id’ => ‘todolist#delete_item’, as: ‘delete’,
constraints: {type: ‘project|task’}

my link:

<%= link_to ‘’, delete_path(type:‘project’,id: project.id),{class:
‘glyphicon glyphicon-trash’,data:{project_id: project.id},remote:
true}%>

I get an error No route matches [GET] “/project/delete/158” WHY GET
method???

routes:
todolist_index GET /todolist/index(.:format) todolist#index
sessions_new GET /sessions/new(.:format) sessions#new
users_new GET /users/new(.:format) users#new
log_out GET /log_out(.:format) sessions#destroy
log_in GET /log_in(.:format) sessions#new
sign_up GET /sign_up(.:format) users#new
root GET / users#new
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
sessions GET /sessions(.:format) sessions#index
POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
edit_session GET /sessions/:id/edit(.:format) sessions#edit
session GET /sessions/:id(.:format) sessions#show
PATCH /sessions/:id(.:format) sessions#update
PUT /sessions/:id(.:format) sessions#update
DELETE /sessions/:id(.:format) sessions#destroy
todo GET /todo_list(.:format) todolist#index
add_project POST /add_project(.:format) todolist#add_project
edit_project POST /edit_project(.:format) todolist#edit_project
POST /:add_task/:id(.:format) todolist#add_task
delete POST /:type/:id(.:format) todolist#delete_item
{:type=>“project|task”}

Andrew D. [email protected] writes:

true}%>
link_to by default uses the GET method. You can tell it to use POST by
supplying method: :post in the parameter hash.

You might consider, since you’re performing a delete action of some
sort,
using the HTTP verb DELETE instead, but that’s entirely up to you.

   sign_up GET    /sign_up(.:format)           users#new
           POST   /sessions(.:format)          sessions#create
    delete POST   /:type/:id(.:format)         todolist#delete_item

{:type=>“project|task”}


Posted via http://www.ruby-forum.com/.


Tamara T.
[email protected]
http://www.tamouse.org

Thx very much. I tried to use method: post but couldn’t figure out how
to do that properly(I mean syntax).So how it should be correctly?!

<%= link_to { delete_path(type:‘project’,id: project.id),remote:
true, method: post},{class:
‘glyphicon glyphicon-trash’,data:{project_id: project.id} do }%>

I concern I passed the wrong route parameters

I fixed thks for help!!!appreciated