Running "rake assets:clobber assets:precompile" will generate files like "application-xxx.css" with incorrect urls after upgrading to Rails 4.
For example url(/fields/xxx.png) when it should be url(/assets/fields/xxx.png). For some unknown reason it worked once in development mode, but after running rake assets:clobber I can't get it to work again...
Any ideas why image-url(fields/sprite.gif) is generating url(/fields/sprite.gif) instead of url(/assets/fields/sprite.gif)?
It happens both in my staging server (running 1.9.3) and in my dev machine (Ruby 2.0.0-p1).
I'm stuck with this enigma.
Any help is greatly appreciated.
Thanks in advance,
I think I’ve narrowed down the problem. For some reason this block
isn’t executed when I run rake assets:precompile:
Maybe that's because I have a class under "lib" that relies on
ActionView::Helpers::NumberHelper, and then I require ‘action_view’.
So, when the hook is registered ‘action_view’ might already be
loaded and the event won’t be triggered. Just guessing of course as
I couldn’t find any documentation about how that on_load method
Then I've written something like this to fix the assets
precompilation for my application:
config = Rails.application.config
Rails.application.assets.context_class.tap do |c|
c.assets_prefix = config.assets.prefix
c.digest_assets = config.assets.digest
c.config = config.action_controller
I'm not sending a pull request because I'm not sure what is the
proper way of fixing it. But I can tell you that if you replace the
line above with “begin” it works.
Open a github issue for the problem; it won’t be addressed otherwise.
I would create an issue if I could replicate the issue in a new
application, but I couldn’t yet.
If I can isolate the problem I'll create a new issue.
Ok, I could finally replicate the issue in development mode for a
new application when I disable the turbolinks gem.
In my application it also happens in production and all other
environments but at least if this is fixed for development mode it
could also fix for my other environments.
I've created this issue:
Here is an application demonstrating the issue: