Undefined method 'patch' - routing error

I am starting to develop Rails and MVC and need help below:

I am doing an example at http://edgeguides.rubyonrails.org/getting_started.html

In "5.12 Updating Messages" we are asked to add the following to our config / routes.rb:

patch "posts/:id" => "posts#update"

      

If I do this and run rake routes

, I get the following error:

undefined method `patch' for #<ActionDispatch::Routing::Mapper:0x390f078>

      

I am getting the same error when I go - http://localhost:3000/posts/1

This is the line in the edit.html.erb file:

<%= form_for :post, url: { action: :update, id: @post.id }, method: :patch do |f| %>

      

I have Rails 3.2.1.

Environment:

I am doing this on Windows 7. I installed Rails via railsinstaller.org. Browsers - Chrome, Firefox

+3


source to share


2 answers


patch

only available in the Rails branch master

.

Among other things, you need to point to the git repo in Gemfile

order to use edge rails in an existing project.



gem 'rails', :git => 'git://github.com/rails/rails.git'

      

You should now use PUT

instead patch

. Even when 4.0 comes out, it's PUT

not going anywhere.

+3


source


fwiw, I kept the HTTP PATCH verb working for Rails 3.2 https://gist.github.com/bf4/8940203



+1


source







All Articles