제품, 제품 컨트롤러 및 레이아웃 제품이 있습니다. 나는 컨트롤러 내부의 레이아웃을 선언했다. css/js/images를 앱 자산 폴더에 추가했습니다. 난 레일 가이드가 내가 커스텀 레이아웃을 원할 때해야한다고 말한 모든 것을했다. 그러나 그것은 여전히 내가 선언 한 레이아웃을 보여주지는 않지만 포맷과 설정없이 기본 페이지를 보여줍니다.뷰가 레일에 제대로 렌더링되지 않았습니다.
제품 컨트롤러
class ProductsController < ApplicationController
layout "product"
# GET /products
# GET /products.json
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
end
을 다음과 같이
내 파일은 내 레이아웃 파일은
<!DOCTYPE html>
<html>
<head>
<title>Cool Amazon Products</title>
<%= stylesheet_link_tag "application" %>
<%= stylesheet_link_tag "bootstrap" %>
<%= stylesheet_link_tag "bootstrap-responsive" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">Cool Products from Amazon</a>
</div>
</div>
</div>
<%= yield %>
<%= javascript_include_tag "bootstrap" %>
</body>
</html>
index.html.erb이다 기본적으로 생성되는 하나입니다!
UI 용으로 트위터 부트 스트랩을 사용하고 있습니다. 올바른 레이아웃을 표시하기 위해 뭔가 잘못된 점이 있다면 알려주십시오.
레이아웃 파일의 전체 이름은 무엇입니까? – smathy
product.html.erb – Jayaram
죄송합니다. 앱의 루트 (즉, 'app' 디렉토리가있는 곳)의 경로를 포함해야합니다. 에서 – smathy