Where to put Galleria (jQuery image gallery framework) in Rails 3.1 Asset Pipeline?

前端 未结 3 1252

I\'m a bit confused as to where to put a jQuery framework like Galleria in Rails 3.1\'s new Asset Pipeline?

I know it, technically

3条回答
  •  时光说笑
    2020-12-28 21:15

    I've also stumbled upon this problem. Dividing up an existing library so it fits into the current javascripts/stylesheets structure is a bit of a hassle. Therefor you can add an extra path to your application.rb file to load assets from, like this:

        # Enable the asset pipeline
        config.assets.enabled = true
        config.assets.paths << "#{Rails.root}/app/assets/libs"
    

    Create a 'libs' folder under app/assets, copy the galleria library to this folder and add this to your application layout file:

        <%= javascript_include_tag 'galleria/galleria-1.2.4.min.js' %>
        <%= javascript_include_tag 'galleria/themes/classic/galleria.classic.min.js' %>
    

    You could also bundle up the galleria code by requiring the js files, but that's up to you.

提交回复
热议问题