2013-10-12 66 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。

相關問題