Rails precompile - all.js missing

萝らか妹 提交于 2021-01-27 18:11:56

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7789233/rails-precompile-all-js-missing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!