Javascript manifest file “application.js” is not processed

隐身守侯 提交于 2019-12-06 21:52:22

问题


I am on a Macbook Pro and I created a new Rails 3.2 app, but the assets pipeline does not work. Here is what I did:

$ rails version
  Rails 3.2.5
$ rails new test_assets
$ cd test_assets
$ rails server

The server is started OK, but if I visit http://0.0.0.0:3000/assets/application.js, it turns out the manifest file is not processed at all, it shows:

//... some comments ...
//= require jquery
//= require jquery_ujs
//= require_tree .
;

I tried to do the exactly the same steps on my other Macbook Pro. It works well. Visiting http://0.0.0.0:3000/assets/application.js on that machine shows a compiled javascript file with all the contents.

I have read http://railscasts.com/episodes/279-understanding-the-asset-pipeline and http://guides.rubyonrails.org/asset_pipeline.html, and I searched for hours on the web but with no clue.

Your help is really appreciated!


回答1:


I had the same issue!

Downgrading Ruby from 2.0.0 to 1.9.3 fixed the issue




回答2:


Suggestions: install node.js or uncomment gem 'therubyracer', :platforms => :ruby in your Gemfile

I followed the same steps and my log file looks like this... What does yours look like if you start the server and request /assets/application.js? As you can see, I'm on 3.2.6, and it compiled my application.js

=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-07-19 22:50:02] INFO  WEBrick 1.3.1
[2012-07-19 22:50:02] INFO  ruby 1.9.3 (2012-02-16) [x86_64-darwin11.3.0]
[2012-07-19 22:50:02] INFO  WEBrick::HTTPServer#start: pid=21393 port=3000


Started GET "/assets/rails.png" for 127.0.0.1 at 2012-07-19 22:50:13 -0500
Connecting to database specified by database.yml
Served asset /rails.png - 200 OK (9ms)


Started GET "/assets/application.js" for 127.0.0.1 at 2012-07-19 22:50:23 -0500
Compiled jquery.js  (2ms)  (pid 21393)
Compiled jquery_ujs.js  (0ms)  (pid 21393)
Compiled application.js  (26ms)  (pid 21393)
Served asset /application.js - 200 OK (74ms)
[2012-07-19 22:50:24] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true



回答3:


Faced exactly the same case.

I've found that I use ruby like v2.0.0rc or something like that, and all works perfect if I downgrade it to 1.9.3p194 (both are under the Rbenv).

Though you can use helper in a view, like <%= javascript_include_tag "jquery", "jquery_ujs" %>, it also helped me even with ruby2.0.0.




回答4:


I have run into the same issue today and I was ready to downgrade Ruby to 1.9.3 from 2.0 to solve the issue of application.js not compiling. The issue happened on the production server, which has Ruby 2.0 installed (and Rails 3.2.8). On the development machine(Ruby 1.9.3 and Rails 3.2.8) application.js compiled just fine.

At last resort, I upgraded the production server from Rails 3.2.8 to 3.2.14; remove Gemfile.lock, and ran bundle install. Then I recompiled the assets, and voila application.js compiled the assets.

I thought of sharing this with Stackoverflow audience, maybe this will solve someone else's issues.




回答5:


The first officially supported version of rails 3.2 with ruby 2.0 is 3.2.13.So upgrade your rails version to rails 3.2.13 will solve the problem.

Step for upgrading:

1)Change rails version in Gemfile to gem 'rails', '3.2.22'.

2)bundle update rails




回答6:


On development the assets are not precompiled. If you want to see them, you should run bundle exec rake assets:precompile.




回答7:


open enviornment/development.rb and set config.assets.debug = false . That's it



来源:https://stackoverflow.com/questions/11571605/javascript-manifest-file-application-js-is-not-processed

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