为什么我无法在本地主机上的 rails 应用程序上显示我的 ruby?

Why can't I display my ruby on rails app on localhost?

我正在尝试显示来自 codecademy 的一个非常简单的应用程序,这是我在浏览器中遇到的错误:

PagesController#welcome is missing a template for request formats: text/html

NOTE! Unless told otherwise, Rails expects an action to render a template with the same name, contained in a folder named after its controller. If this controller is an API responding with 204 (No Content), which does not require a template, then this error will occur when trying to access it via browser, since we expect an HTML template to be rendered for such requests. If that’s the case, carry on.

My directory

pages_controller.rb

class PagesController < ApplicationController
    def welcome
    end
end

routes.rb

Rails.application.routes.draw do
root ‘pages#welcome’
end

application.html.erb

<!DOCTYPE html>
<html>
  <head>
    <title>Portfolio</title>
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,500,700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

  </head>

  <body>
    <%= yield %>
  </body>
</html>

welcome.html.erb

<h1>Hello</h1>

运行 'rails server' 并在我的浏览器中出现上述错误。据我所知,文件位于正确的位置和正确的类型... Rails v 6.0.1

显然问题是我的项目位于一个文件夹中,该文件夹的标题中有一个 space。

将项目移动到其他文件夹后,它现在可以工作了。

这是在 rails 6.0.1

我删除了有问题的控制器和视图以及 auto-generated 控制器和视图

rails g controller controllername new create