首页 > 解决方案 > Rails 的 localhost :“缺少请求格式的模板”?

问题描述

我是 Ruby Rails 新手,我正在尝试通过这个 Youtube 指南制作一个 Rails 页面

https://www.youtube.com/watch?v=pPy0GQJLZUM

当我关注页面时,我遇到了这个问题。当我尝试打开本地主机:localhost:3000 时,它给了我这个通知

PostsController#index is missing a template for request formats: text/html

\app\views\posts我有这样的index.html.erb文件

<h1>Index</h1>

\app\controllers\posts_controller.rb我有这样的posts_controller.rb文件

class PostsController < ApplicationController def index end end

\config\routes.rb我有这样的routes.rb文件 Rails.application.routes.draw do root 'posts#index' end

我是新手,对这个问题很困惑。请你帮助我好吗?非常感谢。

标签: ruby-on-rails

解决方案


推荐阅读