Ruby on Rails 3.1 and jQuery UI images

前端 未结 18 1032
无人及你
无人及你 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:25

    For that moment, I found not a perfect but working a solution.

    Assuming you have jQuery UI theme in the /vendor/assets/stylesheets/ folder. Then you have to modify application.css:

    /* =require ui-lightness */
    

    and create plugin_assets_monkey_patch.rb in the /config/initializers

    Dir[File.join(Rails.root, 'vendor/assets/stylesheets/*/')].each do |dir|
        AppName::Application.config.assets.paths << dir
    
        index_content = '/*=require_tree .*/'
    
        index = File.join(dir, 'index.css')
        unless File.exist?(index)
            File.open(index, 'w') { |f| f.puts index_content }
        end
    end
    

    index.css in every /vendor/assets/stylesheets/ subfolder guarantees that stylesheets like jquery-ui-1.8.11.custom.css will be compiled (if you require that subfolder).

    config.assets.paths ensures that folders like /vendor/assets/stylesheets/ui-lightness/images are visible at the application root scope.

提交回复
热议问题