Rails 3.2.8 Application.js and Application.css are not working as expcted

Deadly 提交于 2019-11-30 08:53:19

It should be ruby version issue. You would be using ruby 2.0.0, try to downgrade to 1.9.2 or 1.9.3. Hope it will work.

Nazar Hussain's answer helped me. It depends on ruby version too. If you are using v.2 then try to downgrade to v.1.9. It is very easy if you are using rvm:

To install v.1.9.3 use:

$ rvm install 1.9.3

To use v.1.9.3 as default:

$ rvm --default use 1.9.3

Then

  • restart your terminal
  • install bundler gem
  • run bundle install
  • run rake assets:clean RAILS_ENV=development
  • start your server rails s

That's all.

I was also having this issue but with newer versions of Rails and Ruby.

Examining the log, I was being served javascript.js from Rails cache as the server didn't see a change in the file. I went and moved the require lines around (just one) to tell Rails that there's a change in the file and re-compile/use. Wellm that did it for me!

Hope it helps somebody.

Another important finding is to upgrade your sprockets gem in your Gemfile.

I had version 2.2.1 and had issues, after upgrading to 2.2.2, it worked

gem 'sprockets', '2.2.2' 

Are you using sass or less or something similar?

I just had this problem and I found it was because the application.css file contained scss code, which it cannot handle by default.

Simply renaming the file to application.css.scss resolved this issue under Rails 4.2.1.

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