Я делаю учебник по http://guides.rubyonrails.org/getting_started.html, создание блога с использованием Rails 5 и Ruby 2.4. После копирования и вставки моего пути до конца Unit-6: добавление модели комментариев Rails выдал эту ошибку:
"NoMethodError in Articles#Show":undefined method `article_comments_path' for #<#
<h2>Add a comment:</h2>
<%= form_for([@article, @article.comments.build]) do |f| %><!--****Error?****-->
A Stackoverflow answer from Oct. 26, 2014 says to add an article_comments_path helper method to routes.rb like this:
resources :articles do
resources :comments
end
Но с тех пор синтаксис, похоже, немного изменился.
Мой route.rb выглядит так:
Rails.application.routes.draw do
resources :articles
resources :comments#This creates comments as a nested resource within articles.
root 'welcome#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
Я не нашел никаких орфографических ошибок, введенных в терминал, поэтому я не совсем уверен, как действовать дальше. Любое руководство приветствуется.
Мои грабли маршруты | вывод комментариев grep:
comments GET /comments(.:format) comments#index
POST /comments(.:format) comments#create
new_comment GET /comments/new(.:format) comments#new edit_comment GET /comments/:id/edit(.:format) comments#edit comment GET /comments/:id(.:format) comments#show PATCH /comments/ :id(.:format) comments#update PUT /comments/:id(.:format) comments#update DELETE /comments/:id(.:format) comments#destroy
и мой вывод rake routes
:
Prefix Verb URI Pattern Controller#Action
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
comments GET /comments(.:format) comments#index
POST /comments(.:format) comments#create
new_comment GET /comments/new(.:format) comments#new
edit_comment GET /comments/:id/edit(.:format) comments#edit
comment GET /comments/:id(.:format) comments#show
PATCH /comments/:id(.:format) comments#update
PUT /comments/:id(.:format) comments#update
DELETE /comments/:id(.:format) comments#destroy
root GET / welcome#index
Любые проблемы?
comments
, запустив в терминале команду rake route | grep комментарии' - person Salil   schedule 12.01.2017