1
votes

Sprockets-rails, which has been moved out of rails and is now its own gem, no longer auto complies assets from gems in the gems respective vendor and lib folders. Meaning you have to add every file from gems vendor and lib folders to either application.js, application.css, or for images/fonts add them each to config.assets.precompile.

https://github.com/rails/rails/pull/7968

How do I restore the default behavior and have it act like it did in rails three?

2

2 Answers

1
votes

This works for me in application.rb

config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
0
votes

In your environments file put the following to restore the old default behavior.

config.assets.precompile += [Proc.new { |path| !%w(.js .css).include?(File.extname(path)) }]

This is lifted directly from the old code.

As of the date of posting this in the current version of sprockets-rails setting config.assets anything is broken, the gem is trying to get the environment before its loaded. But this will work if you patch it yourself or use one of the patched version out there of both sprockets and sprockets-rails.

sprockets-rails https://github.com/rails/sprockets-rails/pull/36

sprockets https://github.com/sstephenson/sprockets/pull/404