2

I have searched around and can't rectify the situation based on the responses to other similar questions. I seem to have broken the asset pipeline somehow but can't seem to figure out how.

None of my assets are being loaded at all; rails seems to just be ignoring my manifest files. When I inspect my page in firebug, only the 'non-compiled' text inside my manifest files (both js and css) is being displayed - almost as if the asset pipeline wasn't even enabled.

I deleted the contents of public/assets since I was adding a new file to the manifest which seemed to start this behavior.

Current configuration:

environments/development.rb

# Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true

application.rb

# Enable the asset pipeline
config.assets.enabled = true
config.assets.manifest = config.root

# Add extra assets for precompiling
config.assets.precompile += ['admin.js', 'admin.css']

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
tjenks
  • 236
  • 4
  • 12
  • 1
    This doesn't seem to have anything to do with js or jquery. – parchment Aug 18 '14 at 09:58
  • assets are not compiled in development mode by default. – Bijendra Aug 18 '14 at 10:01
  • 1
    @parchment - My mistake, I put it there because it's the javascript/jquery which isn't loading. You're right - this is a rails issue. – tjenks Aug 18 '14 at 10:04
  • @GhostRider Reading the Rails documentation of the asset pipeline I was lead to believe that assets in app/assets would be loaded in separate script tags as per the option 'config.assets.debug = true'? Do correct me if I am mistaken. – tjenks Aug 18 '14 at 10:07

4 Answers4

4

I had the same issue. You can still use Ruby 2.1.2, just upgrade rails to latest 3.2.x version - it's 3.2.22

Gemfile:

gem 'rails', '3.2.22'

And run:

$ bundle update rails
Stefan Huska
  • 547
  • 1
  • 7
  • 13
3

The issue was caused by using an incompatible version of ruby. I was using version 2.1.2 which lead to unusual behavior from the sprockets gem (which powers the asset pipeline). This was fixed by downgrading to ruby 1.9.3. I haven't done any experimentation for fear of breaking it again but maybe this has been addressed in later versions of sprockets. I am using sprockets 2.1.3.

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

Community
  • 1
  • 1
tjenks
  • 236
  • 4
  • 12
1

Always remember two things when you want to handle Rails asset pipleline:-

  1. if you want all you newly created js/css to autoinclude in application.js/css,pls add them in... ELSE
  2. IF you dont wont to add in manifest file(application.js/css) then use precompile directive in yuur environment file.

    config.assets.precompile=%w(custom.css,custom2.js...etc)

so make sure you have either of these...

===========for example=-=============

suppose you have new css/js file:- custom.css inside

app/assets/stylesheets/

so you can include in

application.css

// = require 'custom'

OR

use precompile directive:-

config.assets.precompile += %w( custom.css )

and then reference it like you always do

stylesheet_link_tag "custom"

same applies for js also

Milind
  • 4,535
  • 2
  • 26
  • 58
  • All of my js is included in the manifest - it's just not being loaded. I have all the necessary //= require lines. – tjenks Aug 18 '14 at 10:18
0

I just spent a few hours troubleshooting this issue (in 2017!) and it turned out I just needed to remove the gem active_reload. Updating rails and ruby was having no effect for me. The thread where I found that gold is here: https://github.com/rails/rails/issues/2715

Archonic
  • 5,207
  • 5
  • 39
  • 55