jwhitley/requirejs-rails — pull request #138 by andyjeffries (2013-07-08 15:17:01+00:00)
Title: Rails 4 combined asset loading now overloads existing combined assets

In Rails 3.x there's an initializer called "sprockets.environment", so RequireJS-Rails hooks in after that finishes and merges in it's version of (for example) application.js so it goes to the asset with the correct hash digest.

However, in Rails 4 there's no such initializer and it's not even a named initializer, just an "after_initialize" block.

Also, the config.assets.digests hash doesn't exist, it's replaced with a Sprockets::Manifest object which is then instance_eval'd in to ActionView::Base. This pull request creates an object in the same way, then merges in it's assets and reassigns it back in to ActionView::Base (the last step may not be necessary, but I put it in there just for safety.