Rails guides - No route matches [POST] "/articles/new"

I was working my way through Rails Guides getting started tutorial
(Getting Started with Rails — Ruby on Rails Guides). Everything was
going well until the end of 5.2 when I was set to make a blog post. Any
help that could be provided would be greatly appreciated.

Here’s the trace:

No route matches [POST] “/articles/new”

Rails.root: /home/gregb/workspace/blog

Application Trace | Framework Trace | Full Trace
actionpack (4.1.8)
lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in call’
railties (4.1.8) lib/rails/rack/logger.rb:38:in call_app' railties (4.1.8) lib/rails/rack/logger.rb:20:in block in call’
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in tagged’
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in
tagged' railties (4.1.8) lib/rails/rack/logger.rb:20:in call’
actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in
call' rack (1.5.2) lib/rack/methodoverride.rb:21:in call’
rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in call’
rack (1.5.2) lib/rack/lock.rb:17:in call' actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:in call’
rack (1.5.2) lib/rack/sendfile.rb:112:in call' railties (4.1.8) lib/rails/engine.rb:514:in call’
railties (4.1.8) lib/rails/application.rb:144:in call' rack (1.5.2) lib/rack/lock.rb:17:in call’
rack (1.5.2) lib/rack/content_length.rb:14:in call' rack (1.5.2) lib/rack/handler/webrick.rb:60:in service’
/home/gregb/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in
service' /home/gregb/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in run’
/home/gregb/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in
`block in start_thread’
Routes

Routes match in priority from top to bottom

Helper HTTP Verb Path Controller#Action
Path / Url
welcome_index_path GET /welcome/index(.:format) welcome#index
root_path GET / welcome#index
articles_path GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article_path GET /articles/new(.:format) articles#new
edit_article_path GET /articles/:id/edit(.:format) articles#edit
article_path GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy

On 2015-Feb-5, at 13:49 , Greg B. [email protected] wrote:

I was working my way through Rails Guides getting started tutorial
(Getting Started with Rails — Ruby on Rails Guides). Everything was
going well until the end of 5.2 when I was set to make a blog post. Any
help that could be provided would be greatly appreciated.

Here’s the trace:

No route matches [POST] “/articles/new”

Presumably, you have: new_article_path in your form_for, but you ought
to have: articles_path

See the routes listing you have below that only has GET for the
/articles/new path and the path which routes to articles#create is a
POST to /articles (same as the GET uses for articles#index)

-Rob

That seems to work! Thanks so much, Rob!

Note from a Ruby newbie. The reason I missed the articles_path option in the form is because I accidentally skipped the " Edit the form_with line inside app/views/articles/new.html.erb to look like this:" line on accident and didn’t update the form to <%= form_with scope: :article, url: articles_path, local: true do |form| %>

Moral of the story: Read the instructions thoroughly.