2013-10-12 34 views
0

我有我的主要应用CSS和我想排除我的后端样式,因为样式都流血了,当application.css执行*=require_tree .样式表在Rails应用程序不正确作用域

目前,我有我的文件夹的设置,像这样:

assets/ 
    stylesheets/ 
     main/ #application.css ##other css files for front end 
     backend/ #backend.css ##other css files for back end 

我application.css如下:

/* 
*= require_self 
*= require foundation_and_overrides 
*= require_tree ./main/ 
*/ 

backend.css

/* 
*= require_self 
*= require foundation_and_overrides 
*= require_tree ./backend/ 
*/ 
在我的application.rb中

config.assets.precompile += ['application.css', 'backend.css'] 

我development.rb

config.cache_classes = false 

    # Do not eager load code on boot. 
    config.eager_load = false 

    # Show full error reports and disable caching. 
    config.consider_all_requests_local  = true 
    config.action_controller.perform_caching = false 

    # Don't care if the mailer can't send. 
    config.action_mailer.raise_delivery_errors = false 

    # Print deprecation notices to the Rails logger. 
    config.active_support.deprecation = :log 

    # Raise an error on page load if there are pending migrations 
    config.active_record.migration_error = :page_load 

    # Debug mode disables concatenation and preprocessing of assets. 
    # This option may cause significant delays in view rendering with a large 
    # number of complex assets. 
    config.assets.debug = true 

我试着走动的样式表,并用不同的目录玩,但我想要么样式表无法加载

在所有或将收到“找不到foundation_and_overrides”...

有没有一个简单的干净的方式来做到这一点? 我只是想排除几个样式表与application.css编译

回答

1

链轮的重点是你包括你所需要的。总是可以将其他样式表添加到页面中。与用户编译成一个很好的做法,但如果管理员使用后端,添加另一个样式表就完全没问题。

首先,application.css已经预编译,所以你只需要:

config.assets.precompile << 'backend.css' 

可选包括附加的样式表,所以application.css有基础等,并backend.css刚刚附加的造型:

<%= stylesheet_link_tag 'application', media: :all %> 
<% if admin? %> 
    <%= stylesheet_link_tag 'backend', media: :all %> 
<% end %> 

如果由于某种原因,application.css样式会与冲突,您也可以为样式表添加shared目录款式。

+ stylesheets 
    + shared 
    + app 
    + backend 
    - application.css 
    - backend.css 

and require_tree ./shared in both。

相关问题