Rails预编译-缺少all.js [英] Rails precompile - all.js missing
问题描述
我是Rails的新手,正在使用3.1.0版并尝试部署到heroku.我有一个非常简单的应用程序,在解决了一些问题之后,我已经设法在heroku上启动并运行.我使用了命令
捆绑执行耙资产:预编译
让heroku加载应用程序的资产(我读到heroku在版本3.1.0中需要这样做).问题是,当我尝试运行该应用程序时,服务器给出了错误
ActionController :: RoutingError(没有路由与[GET]"/assets/all.js"匹配):
我在 public/javscripts 中拥有所有必需的javascript文件,但在资产目录中找不到all.js的任何版本.我已包含
config.assets.precompile<<'* .js'
在 config/application.rb 中,但无济于事.
我想知道是否有人可以告诉我如何在资产目录中创建pre.compile来创建all.js,或者我是否完全偏离了正常轨道.我给人的印象是,预编译功能将所有javascript文件编译为一个优化的文件.
此外,如果任何人都有任何良好的链接供初学者了解预编译功能如何在rails中工作,我将不胜感激.
谢谢.
阅读上面的资源,如果您要转换现有的应用程序,请观看Railscast并遵循指南的最后部分-这些应该为您指明正确的方向.
I am new to rails and using version 3.1.0 and trying to deploy to heroku. I have a very simple application that i have managed to get up and running on heroku after working my way through several issues. I used the command
bundle exec rake assets:precompile
to get heroku to load the assets for the application (i read that heroku requires this for version 3.1.0). The problem is that when i try to run the application, the server gives the error
ActionController::RoutingError (No route matches [GET] "/assets/all.js"):
i have all of the required javascript files in public/javscripts but i cannot find any version of all.js in the assets directory. I have included
config.assets.precompile << '*.js'
in config/application.rb but to no avail.
I was wondering if someone could tell me how I get the precompile to create all.js in the assets directory or if I am completely off track here. i was under the impression that the precompile function compiled all of the javascript files into a single optimized file.
Also, if anyone has any good links for a beginner to understand how the precompile functionality works in rails I would be very appreciative.
Thanks in advance.
The best guide is the official rails guide. There is also the Railscast about it.
In a nutshell your Javascript files go in app/assets/javascript from where the precompile task will process them and put then in the public/assets directory. You should not have to change the precompile config option if the follow the defaults. Don't forget to the use the correct helpers to reference your files.
Read the resources above, and if you are converting an existing app watch the Railscast and follow the last section of the guide - these should point you in the right direction.
这篇关于Rails预编译-缺少all.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!