How to get EXTJS 4 inside the Rails 3.1 asset pipeline?
I recently started working with Rails 3.1. It's a very nice framework and I like the 'asset pipeline' philosophy. Adding libraries that exist of one file is quite easy and works out of the box. However, adding a library which exists of a folder like EXTJS 4 is somewhat more difficult.
I'd like to just add the whole EXTJS4 folder to the '/app/assets' folder And do a //= require_tree in my 'application.js' file but that does not include the css files. Also images and scss files are not included this way. All the images/css files are referenced 'relatively' from the js file so I think the fo开发者_如何学Clder structure should be maintained as it is.
What is the best and easiest way to add this library to my rails projects? I dont want to specify the whole list of EXTJS resources to my view each time I create a new view.
Thanks
Simply leaving the Ext library (linked) inside of "public" works just fine.
One caveat here: keep in mind, that if you want sprockets to not interfere, then, while using Rails view helpers, you need the paths to your extjs JS and CSS files to be absolute, e.g. starting with "/". Let's say we have the Ext library in "public/extjs". Then these 2 calls will be needed in your Rails view/layout:
javascript_include_tag "/extjs/ext-all-debug"
stylesheet_link_tag "/extjs/resources/css/ext-all"
精彩评论