Ruby on Rails 3.1 and jQuery UI images

前端 未结 18 995
无人及你
无人及你 2020-12-12 11:50

I\'m using Ruby on Rails (Edge, the development version), and Ruby rvm 1.9.2.

application.js is as follows.

//= require jquery
//= requi         


        
18条回答
  •  温柔的废话
    2020-12-12 12:31

    So, here's one way to do it that lacks the downsides of some of the others mentioned here -- it doesn't require you to take apart the theme and put parts of it in different places, it doesn't require symbolic links, and it still allows you to compile the theme css into the one main css as part of the asset pipeline. It does not require a monkey patch like Nash Bridges' suggestion.

    However, it does require an additional kind of hacky configuration line. (a one-liner though, basically).

    Okay, put your theme in vendor/assets/jquery/ui-lightness/, like you wanted to. (will also work in lib/assets or app/assets, same way).

    And

    /* =require ui-lightness */
    

    in your application.css. So far so good. Now to get the images to show up right, just add this to config/application.rb:

    initializer :add_jquery_ui_asset_base, :group => :all, :after => :append_assets_path do
       config.assets.paths.unshift Rails.root.join("vendor", "assets", "stylesheets", "jquery-ui", "ui-lightness").to_s
    end
    

    For me, it now works in dev, production, and other non-standard asset configs I could think of (like dev with debug=false, which trips up some of the other attempted solutions).

    More info at http://bibwild.wordpress.com/2011/12/08/jquery-ui-css-and-images-and-rails-asset-pipeline/

提交回复
热议问题