I have seen many questions and differing answers on using the jQuery plugins in the Rails 3.1 asset pipeline, which leads me to believe that this is new enough that it isn't settled science. I have tried using my jQuery plugins in the pipeline, but ran into issues when it came to incorporating the plugin stylesheets.

Now I am trying to back out of that solution, and only put my jQuery plugins and their associated themes and stylesheets in the traditional locations under "public". So, a sort of mixed solution. Then I put the tags back in my layout file to reference these directly.

Of course, now my problem is that Rails only knows to use the asset pipeline, and it's looking in "/assets" for them. They ain't there no more though.

Is there a right way to do this? I don't want to modify these plugins at all, so no changing of the stylesheets or anything else, I want them to just work at this point. Barring a correct way to use jQuery plugins in the Rails 3.1 asset pipeline, is there a way to make Rails use the traditional paths in addition to /assets?

有帮助吗?

解决方案

I'm using a tiny gem sprockets-urlrewriter. Citing the readme:

Rewrites relative CSS urls to absolute ones, which means that you can include, for example jQuery UI, without any modifications into the asset pipeline.

So you can put the files in their respective directories and the gem will care about the asset pipeline.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top