2012-04-23 9 views
0

私のアプリケーションのshow.html.hamlページだけで特定のテーブルスタイルを使用する必要があります。具体的には、このスタイルを_form.html.haml partialのフォームには適用したくありません。ここでは、スタイルの要素は次のとおりです。 Ruby on Railsのcssアセットパイプラインの組織化問題

table { 
    border-collapse: collapse; 
    width:100%; 
    } 

    td, th { 
    border: 1px solid gray; 
    padding:5px; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
    overflow: ellipsis; 
    } 

    th { 
    background-color: #ccc; 
    text-shadow: 1px 1px 1px rgba(0,0,0,.2); 
    } 

は、私は私のアプリ/ベンダー/資産/ウェブアプリ-テーマ/スタイルシートディレクトリ内data_tables.cssと呼ばれる小さなファイルを作成し、そのように私application.jsでそれを含める:

* =必要なWebアプリ・テーマ/ data_tables

トラブルがある:それは(だけでなく、(私はしたい)私のshow.html.hamlページ内のテーブルも_form_html.hamlのパーシャルに影響を与えるIドン欲しい)。明らかに、私は資産組織について完全に理解していないことがあります。ここに私のapplication.cssファイルの内容は、アプリ/資産/スタイルシートのディレクトリにある:あなたがマニフェストに宣言

/* 
* This is a manifest file that'll automatically include all the stylesheets available in this directory 
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 
* the top of the compiled file, but it's generally better to create a new file per style scope. 
*= require web-app-theme/base 
*= require web-app-theme/style 
*= require web-app-theme/wat_ext 
*= require web-app-theme/data-tables 
*= require formalize 
*= require jquery.ui.core 
*= require jquery.ui.theme 
*= require jquery.ui.tabs 
*= require dataTables/src/demo_table_jui 
*= require_self 
*= require_tree . 
*/ 

答えて

1

すべてが資産のコンパイル時に単一のファイルにダンプされます。あなたの問題を解決する最善の方法は、CSSが影響を与えるテーブルにクラスを割り当て、それに応じて変更することです。また

あなたがマニフェストからこのファイルを削除して、このようなstylesheet_link_tagとの意見からそれを呼び出すことができます。

<%=stylesheet_link_tag "web-app-theme/data_tables"%> 

をしかし、それはあなたのサーバーへのリクエストの量が増加するので、それは、あなたが小さなファイルに使用したいものではありません何もない

+0

ありがとうございます。私はあなたの助言に従って、特定のクラス(および関連する要素)を作成しました。これは最適です。 – Bharat