【发布时间】:2018-05-07 12:48:31
【问题描述】:
我创建了一个项目,其中 index.html.erb 无法正确呈现,当我使用 application.html.erb 以及删除该文件时一切正常
Home Controller
class HomeController < ApplicationController
end
Routes file
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root "home#index"
resources :posts
end
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Project</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield%>
</body>
</html>
【问题讨论】:
-
“index.html.erb 未正确呈现” - 您能否添加更多详细信息,说明哪些内容无法正常工作?
-
你的路由包含
root "home#index",但是你没有在HomeController中定义index方法,即。def index ....
标签: ruby-on-rails ruby render