Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a "Rails Way" include a jQuery plugin in the Asset Pipeline?

Many jQuery plugins have the following directory structures:

/<plugin name>
../css
../images
../js

The CSS files usually have relative links to the images in them. What I want to do is include these plugins in the Rails Way under the Asset Pipeline, and hopefully that doesn't involve having to renamed the file references to remove the relative links. Is there such a Rails Way?

Could it also be that it's overkill to include an already-minified jQuery plugin in the Asset Pipeline?

like image 610
AKWF Avatar asked Feb 06 '13 20:02

AKWF


People also ask

How does Rails asset pipeline work?

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.

What is JQ plugin?

A jQuery plugin is simply a new method that we use to extend jQuery's prototype object. By extending the prototype object you enable all jQuery objects to inherit any methods that you add. As established, whenever you call jQuery() you're creating a new jQuery object, with all of jQuery's methods inherited.


1 Answers

You should try to add your assets to the load path which is the recommended way, as far as I know. If the application you're running has the assets-pipeline activated, it should find your assets after expanding the path in your application.rb

config.assets.paths << Rails.root.join("plugins/plugin_name/assets/")

Not shure, if this is what you asked for but if not, you should check: http://guides.rubyonrails.org/asset_pipeline.html#asset-organization

Remeber to restart your server

like image 143
Rob Avatar answered Dec 13 '22 14:12

Rob