如何将自定义布局添加到Rails资产管道

时间:2015-05-01 15:36:37

标签: css ruby-on-rails ruby ruby-on-rails-4

我在应用的不同部分使用不同的布局。在我的控制器中,我有:

def index
    @user = current_user
    @orders = @user.orders.all
    render layout: 'admin'
end

OR

class ProductsController < ApplicationController
    layout "inventory"
    #...
end

我的资产中有layout_theme.css.scsslayout_login.css.scss

在我的views/layouts我已经theme.html.hamllogin.html.haml等。

在设置我的应用程序进行生产并使用以下命令预编译资产后:bundle exec rake assets:precompile --trace

当我尝试加载页面时,我只收到两个资产请求:layout_theme.csslayout_theme.js并且出错。

我已尝试将其添加到我的config/application.rb

config.assets.precompile += %w( layout_home.css layout_home.js layout_login.css layout_login.js layout_theme.css layout_theme.js )

其中包含我使用的其他文件,但它没有用。我错过了什么?

编辑:我可以看到在public / assets / layout_theme ... css和public / assets / layout_theme ... js中编译的文件,但似乎rails没有引用应用程序中的编译文件

0 个答案:

没有答案