我正在尝试在localhost:3000/posts
上发布简单的博文。
当我尝试访问该页面时,收到此错误。
Template is missing
Missing template posts/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "c:/Sites/myrubyblog/app/views"
以下是我posts_controller.rb
中的代码副本:
class PostsController < ApplicationController
def index
end
end
我的index.html.erb
目录中有c:/Sites/myrubyblog/app/views
文件,所以我不确定为什么会这样。
有谁能告诉我应该怎么做才能解决这个问题?
答案 0 :(得分:0)
将index.html.erb
移至posts
文件夹内的rubyblog/app/views/posts
。
答案 1 :(得分:0)
您的index.html.erb
文件应位于c:/Sites/myrubyblog/app/views/posts
。
答案 2 :(得分:0)
您应该将视图代码放在相应的文件夹中。
在您的情况下,您应将index.html.erb
放入c:/Sites/myrubyblog/app/views/posts/
文件夹
模板丢失当它无法找到视图文件时出现错误。