C
C
Ciscoridze2016-03-15 16:20:24
Ruby on Rails
Ciscoridze, 2016-03-15 16:20:24

Why do I send GET instead of DELETE in Rails 4.2.6?

There is a standard CRUD.

[email protected]:/var/www/remember$ rake routes
         Prefix Verb   URI Pattern                  Controller#Action
           root GET    /                            question#view
 question_index GET    /question(.:format)          question#index
                POST   /question(.:format)          question#create
   new_question GET    /question/new(.:format)      question#new
  edit_question GET    /question/:id/edit(.:format) question#edit
       question GET    /question/:id(.:format)      question#show
                PATCH  /question/:id(.:format)      question#update
                PUT    /question/:id(.:format)      question#update
                DELETE /question/:id(.:format)      question#destroy
question_create GET    /question/create(.:format)   question#create
  question_view GET    /question/view(.:format)     question#view

def destroy
    @question = Question.find(params[:id])
    @question.destroy
    redirect_to root_path
  end

This helper sends not to destroy, but to show:
<%= link_to "Destroy", question_path(question), :method => :delete, data: { confirm: 'Are you sure?' } %>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zaporozhchenko Oleg, 2016-03-17
@c3gdlk

The method is substituted using javascript
It must be enabled and the following files must be included in your manifest

#= require jquery
#= require jquery_ujs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question