如何在 Rails 3.1 资源管道中获取 EXTJS 4?
我最近开始使用 Rails 3.1。这是一个非常好的框架 我喜欢“资产管道”理念。添加现有的库 一个文件的操作非常简单,并且开箱即用。但是,添加一个库 存在像 EXTJS 4 这样的文件夹有点困难。
我想将整个 EXTJS4 文件夹添加到“/app/assets”文件夹中 并在我的“application.js”文件中执行 //= require_tree 但这并不 包含 css 文件。此外,图像和 scss 文件也不以这种方式包含在内。 所有图像/css 文件都是从 js 文件“相对”引用的,因此 我认为文件夹结构应该保持原样。
将此库添加到我的 Rails 项目中的最佳和最简单的方法是什么? 我不想每次都在我的视图中指定 EXTJS 资源的完整列表 我创建一个新视图。
谢谢
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 folder 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将 Ext 库(链接)留在“public”中就可以了。
这里需要注意一点:请记住,如果您希望 sprocket 不干扰,那么在使用 Rails 视图助手时,您需要 extjs JS 和 CSS 文件的路径是绝对的,例如以“/”开头。假设我们在“public/extjs”中有 Ext 库。那么你的 Rails 视图/布局中将需要这两个调用:
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: