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

后端 未结 4 1257
野性不改
野性不改 2020-12-31 11:04

When i try to include

<%= stylesheet_link_tag    \"application\" %>
<%= javascript_include_tag \"application\" %>

The content

相关标签:
4条回答
  • 2020-12-31 11:51

    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.

    0 讨论(0)
  • 2020-12-31 11:53

    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.

    0 讨论(0)
  • 2020-12-31 11:53

    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.

    0 讨论(0)
  • 2020-12-31 11:56

    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' 
    
    0 讨论(0)
提交回复
热议问题