【发布时间】:2017-01-02 03:47:00
【问题描述】:
我不断收到以下错误。我正在尝试开发自己的博客平台,以此作为我学习和变得更好的一种方式。
错误:
显示 /home/ubuntu/workspace/app/views/posts/show.html.erb 在哪里 第 36 行提出:
未定义的方法`post_cmets_path' 你的意思是?帖子路径
app/views/posts/show.html.erb
<h2>Add a comment:</h2>
<%= form_for([@post, @post.comments.build]) do |f| %>
<div class="field">
<%= f.label :author %><br />
<%= f.text_field :author %>
config/routes.rb
Rails.application.routes.draw do
get 'welcome/index'
resources :posts
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root :to => "posts#index"
end
【问题讨论】:
-
发布您的路线文件。
-
Rails.application.routes.draw do get 'welcome/index' resources :posts # 有关此文件中可用 DSL 的详细信息,请参阅guides.rubyonrails.org/routing.html root :to => "posts#index"结束
标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 ruby-on-rails-3.2