Ruby on rails 文章中的命名错误#在遵循RoR指南第6.4步创建博客后显示
我是RoR的新手,我正试着在 我目前在第6节第4点,但我被困在这里 我得到了以下错误:文章中的命名错误#show 这是我的“rake路由”输出Ruby on rails 文章中的命名错误#在遵循RoR指南第6.4步创建博客后显示,ruby-on-rails,ruby,Ruby On Rails,Ruby,我是RoR的新手,我正试着在 我目前在第6节第4点,但我被困在这里 我得到了以下错误:文章中的命名错误#show 这是我的“rake路由”输出 Prefix Verb URI Pattern Controller#Action article_commments GET /articles/:article_id/commments(.:format)
Prefix Verb URI Pattern Controller#Action
article_commments GET /articles/:article_id/commments(.:format) commments#index
POST /articles/:article_id/commments(.:format) commments#create
new_article_commment GET /articles/:article_id/commments/new(.:format) commments#new
edit_article_commment GET /articles/:article_id/commments/:id/edit(.:format) commments#edit
article_commment GET /articles/:article_id/commments/:id(.:format) commments#show
PATCH /articles/:article_id/commments/:id(.:format) commments#update
PUT /articles/:article_id/commments/:id(.:format) commments#update
DELETE /articles/:article_id/commments/:id(.:format) commments#destroy
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
怎么了?我从网站上复制并粘贴了代码,以查看我做错了什么,但我仍然无法解决问题
提前感谢您的帮助 您的
routes.rb中有一个打字错误。word注释中有3个m
字母,而不是此处的2个:
Rails.application.routes.draw do
resources :articles do
resources :commments
end
end
class CommentsController < ApplicationController
def create
@article = Article.find(params[:article_id])
@comment = @article.comments.create(comment_params)
redirect_to article_path(@article)
end
private
def comment_params
params.require(:comment).permit(:commenter, :body)
end
end
Rails.application.routes.draw do
resources :articles do
resources :commments
end
end
Prefix Verb URI Pattern Controller#Action
article_commments GET /articles/:article_id/commments(.:format) commments#index
POST /articles/:article_id/commments(.:format) commments#create
new_article_commment GET /articles/:article_id/commments/new(.:format) commments#new
edit_article_commment GET /articles/:article_id/commments/:id/edit(.:format) commments#edit
article_commment GET /articles/:article_id/commments/:id(.:format) commments#show
PATCH /articles/:article_id/commments/:id(.:format) commments#update
PUT /articles/:article_id/commments/:id(.:format) commments#update
DELETE /articles/:article_id/commments/:id(.:format) commments#destroy
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
Rails.application.routes.draw do
resources :articles do
resources :commments
end
end