Rails 3.1 and jquery-ui assets

后端 未结 8 1821
小鲜肉
小鲜肉 2020-12-02 05:10

This was asked in another question, but none of the solutions appear to work for me in 3.1rc1.

I\'m trying to use the new assets stuff in rails 3.1 - I have the file

8条回答
  •  攒了一身酷
    2020-12-02 05:28

    It seems to me that a lot of confusion can be avoided by keeping these library assets out of assets/javascripts and assets/stylesheets dirs, where sprockets et al have some opinions about what should happen.

    Say you've downloaded a customized jquery-ui zipfile from the themeroller. Try this:

    1. unpack the zip file into an subdir of an assets dir, something like

      vendor/assets/jquery-ui-1.8.23.custom
      
    2. in application.rb add:

      config.assets.paths << Rails.root.join('vendor', 'assets', 'jquery-ui-1.8.23.custom').to_s
      
    3. add manifest files in the usual places:

      vendor/assets/javascripts/jquery-ui.js:

      //= require_tree ../jquery-ui-1.8.23.custom
      

      vendor/assets/stylesheets/jquery-ui.css:

      *= require_tree ../jquery-ui.1.8.23.custom
      
    4. in config/environments/production.rb, add (referring to manifest filenames):

      config.assets.precompile += %w(jquery-ui.js jquery-ui.css)
      
    5. in views:

      <%= stylesheet_link_tag 'jquery-ui' %>
      <%= javascript_include_tag 'jquery-ui' %>
      

提交回复
热议问题