ruby-on-rails – Rails“模板丢失”错误,尽管它存在(3.2.1)

我刚开始使用Rails,我不确定我做得不好.

在routes.rb我有

resources :pages

在app / controllers / pages_controller.rb我有

class PagesController < ApplicationController
  def index
  end
end

我在app / views / layouts / application.html.erb中有一个布局,在app / views / home / pages / index.html.erb中有一个模板,当我请求“/ pages”时我要渲染它.但是,我得到了错误

Template is missing

Missing template pages/index,application/index with {:locale=>[:en],
:formats=>[:html],:handlers=>[:erb,:builder,:coffee]}. Searched in:
* “/###/app/views”

我已经使用stackoverflow多年没有发布,但是很多不同的东西似乎触发了这个错误,很难找到我特定情况的答案.我也是菜鸟:3请帮忙!

解决方法

你说你有app / views / home / pages / index.html.erb来表示你的页面资源的索引视图.我认为主页/目录不是必需的.

换句话说,您的视图文件应该是app / views / pages / index.html.erb.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...