Andrew Dig <[email protected]> writes:

> 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}%>

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.


>
> 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"}
>
> --
> Posted via http://www.ruby-forum.com/.

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

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/m2vb5fiswk.fsf%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to