我创建了一个项目,其中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>
答案 0 :(得分:0)
您需要在index
的{{1}}中定义您引用的routes.rb
操作。为此,您必须在HomeController
中定义index
方法,因此:
HomeController