我在學習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