我在学习Ruby-on-Rails
。为此我有一个'你好世界'样本。 这就是我的config/routes.rb
:Rails中缺少模板
Rails.application.routes.draw do
root 'application#show'
end
controllers/application_controller.rb
:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def show
render 'startpage'
end
end
最后我views/startpage.html.erb
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hello World!</title>
</head>
<body id="index" class="home"><h1>Hello World!!</h1>
</body>
</html>
但是,当我打开我的网站我得到这个错误:
Template is missing
Missing template application/startpage with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/home/ubuntu/workspace/app/views"
那么,我是否错过了一些东西,或者在其他地方有startpage.html.erb
文件?
将您的views/startpage.html.erb文件移动到views/application/startpage.html.erb – Jaxx