I am beginner in Rails & MVC development, and need help with the below:
I am doing the example in http://edgeguides.rubyonrails.org/getting_started.html
In "5.12 Updating Posts", we are asked to add the following to our config/routes.rb:
patch "posts/:id" => "posts#update"
If I do that, and run rake routes, I am getting the below error:
undefined method `patch' for #<ActionDispatch::Routing::Mapper:0x390f078>
I get the same error when I go to - http://localhost:3000/posts/1
This is the line in edit.html.erb :
<%= form_for :post, url: { action: :update, id: @post.id }, method: :patch do |f| %>
I have Rails 3.2.1.
I am doing this in Windows 7. I installed Rails via railsinstaller.org. Browsers - Chrome, Firefox
patch is only available in Rails master branch.
Among other things, you need to point to the git repo in your Gemfile to use edge rails on an already-existing project.
gem 'rails', :git => 'git://github.com/rails/rails.git'
For now you should just use PUT instead of PATCH. Even when 4.0 comes out, PUT isn't going anywhere.
fwiw, I backported the HTTP PATCH verb work for Rails 3.2 https://gist.github.com/bf4/8940203
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With