2017-11-23 10 views
-1

index.html.erb가 제대로 렌더링되지 않는 프로젝트를 만들었고 application.html.erb를 사용할 때 그 파일을 제거하면 모든 것이 잘 작동합니다index.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

_ _ "index.html.erb가 제대로 렌더링되지 않는다"- 아니 정확히 당신이에 대한 몇 가지 세부 사항을 더 추가 할 수 있습니다 일? – mikej

+0

@mikej 이것은 application.html.erb [link] (https://www.dropbox.com/s/akdo20maryywjn5/After.jpg?dl=0)를 추가 한 후입니다. application.html.erb를 추가하기 전입니다. [link] (https://www.dropbox.com/s/qg4y72qr9myt4vq/Before.jpg?dl=0) –

+0

루트에는'root "home # index"'가 포함되어 있지만 인덱스 메소드는 다음과 같이 정의되어 있지 않습니다. HomeController, 즉. 'def index ... '. – assefamaru

답변

0

routes.rb에서 참조하는 작업을 HomeController에 정의해야합니다. 이렇게하려면, 당신은 그래서 HomeControllerindex 방법을 정의해야 할 것 :

# home_controller.rb 
class HomeController < ApplicationController 
    def index; end 
end