我有一个模型 - Products,ProductsController和布局产品。我在控制器内声明了布局。将css / js / images添加到app assets文件夹。当我想要一个自定义布局时,我做了导轨指导告诉我要做的所有事情。但它仍然没有显示我声明的布局,但显示了没有任何格式和设置的默认页面。
我的文件如下
产品控制器
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使用twitter bootstrap。如果我遗漏了某些东西以便显示正确的布局,请告诉我。
答案 0 :(得分:0)
好的,很奇怪,这应该有用。
所以,要检查的事情:
这就是造成这种情况的所有原因。