4

Rails キャスト #340 に従って、アプリケーションにデータ テーブルを実装しています。

すべての手順を実行すると、次のエラーが表示されます: ファイル 'dataTables/jquery.dataTables' が見つかりませんでした

Rails 4 を使用していますが、チュートリアルで言及されているいくつかのファイルを、application.css や products.js.coffee のように作成する必要があることがわかりました。

Gemfile

gem 'jquery-rails'
group :assets do 
  gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
  gem 'jquery-ui-rails'
end

アプリケーション.js

//= require jquery
//= require dataTables/jquery.dataTables
//= require_tree .

アプリケーション.js.コーヒー

 /* 
 * 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_self 
 *= require dataTables/jquery.dataTables 
 *= require_tree .  
*/  

Rails 4と同様に、/layouts/application.html.erbにスタイルシートへの呼び出しを追加しました

<%= stylesheet_link_tag 'application.css', media: 'all' %>

そしてproducts/index.htm.erb

<table class="table table-normal" id="products" >
  <thead>
    <tr>
                      <td>Code</td>
                      <td>Name</td>
                      <td>Description</td>
                      <td>Price</td>
                      <td>Stock</td>
                      <td>Enabled</td>
                      <td>Company</td>
              </tr>

  </thead>

  <tbody>   

    <% @products.each do |product| %>
      <tr>                          
            <td style="text-decoration: underline;"><%= link_to product.code, edit_product_path(product) %></td>             

            <td><%= product.name %></td>             

            <td><%= product.description %></td>              

            <td><%= product.price %></td>              

            <td><%= product.stock %></td>              

            <td><%= product.enabled %></td>              

            <td><%= product.company_id %></td>              

      </tr>
    <% end %>
  </tbody>
</table>

出力にこのエラーが表示されます

ファイル 'dataTables/jquery.dataTables' が見つかりませんでした (....app/assets/stylesheets/application.css:6 内)

これを解決する方法はありますか?前もって感謝します

4

2 に答える 2

6

Rails 4 には :assets グループがなくなったので、そのブロックから gem を取り出してください。

于 2013-11-01T05:04:29.497 に答える