Rodrigo Rosenfeld Rosas
2013-Feb-27 01:04 UTC
My SCSS compiled CSS lacks "/assets" in the generated urls
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, Rodrigo. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Rodrigo Rosenfeld Rosas
2013-Feb-27 03:18 UTC
Re: My SCSS compiled CSS lacks "/assets" in the generated urls
I think I''ve narrowed down the problem. For some reason this block isn''t executed when I run rake assets:precompile: https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L86 ActiveSupport.on_load(:action_view) do... 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 works. Then I''ve written something like this to fix the assets precompilation for my application: def fix_asset_precompiling 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 end end 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. - ActiveSupport.on_load(:action_view) do + begin But I don''t know what is the reason for the on_load hook, so I won''t change anything. I''d just like to let you know about this problem. This is a new bug and doesn''t exist on Rails 3. Best, Rodrigo. Em 26-02-2013 22:04, Rodrigo Rosenfeld Rosas escreveu:> 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, > Rodrigo. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Andrew Kaspick
2013-Feb-27 04:10 UTC
Re: Re: My SCSS compiled CSS lacks "/assets" in the generated urls
Open a github issue for the problem; it won''t be addressed otherwise. On Tue, Feb 26, 2013 at 9:18 PM, Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com> wrote:> I think I''ve narrowed down the problem. For some reason this block isn''t > executed when I run rake assets:precompile: > > > https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L86 > > ActiveSupport.on_load(:action_view) do... > > 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 works. > > Then I''ve written something like this to fix the assets precompilation for > my application: > > def fix_asset_precompiling > 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 > end > end > > 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. > > - ActiveSupport.on_load(:action_view) do > + begin > > But I don''t know what is the reason for the on_load hook, so I won''t > change anything. I''d just like to let you know about this problem. This is > a new bug and doesn''t exist on Rails 3. > > Best, > Rodrigo. > > Em 26-02-2013 22:04, Rodrigo Rosenfeld Rosas escreveu: > > 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, > Rodrigo. > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Rodrigo Rosenfeld Rosas
2013-Feb-27 13:54 UTC
Re: Re: My SCSS compiled CSS lacks "/assets" in the generated urls
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. Em 27-02-2013 01:10, Andrew Kaspick escreveu:> Open a github issue for the problem; it won''t be addressed otherwise. > > On Tue, Feb 26, 2013 at 9:18 PM, Rodrigo Rosenfeld Rosas > <rr.rosas@gmail.com <mailto:rr.rosas@gmail.com>> wrote: > > I think I''ve narrowed down the problem. For some reason this block > isn''t executed when I run rake assets:precompile: > > https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L86 > > ActiveSupport.on_load(:action_view) do... > > 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 works. > > Then I''ve written something like this to fix the assets > precompilation for my application: > > def fix_asset_precompiling > 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 > end > end > > 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. > > - ActiveSupport.on_load(:action_view) do > + begin > > But I don''t know what is the reason for the on_load hook, so I > won''t change anything. I''d just like to let you know about this > problem. This is a new bug and doesn''t exist on Rails 3. > > Best, > Rodrigo. > > Em 26-02-2013 22:04, Rodrigo Rosenfeld Rosas escreveu: >> 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, >> Rodrigo. >> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Rodrigo Rosenfeld Rosas
2013-Feb-27 14:36 UTC
Re: Re: My SCSS compiled CSS lacks "/assets" in the generated urls
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: https://github.com/rails/rails/issues/9461 Here is an application demonstrating the issue: https://github.com/rosenfeld/assetsbug Em 27-02-2013 10:54, Rodrigo Rosenfeld Rosas escreveu:> 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. > > Em 27-02-2013 01:10, Andrew Kaspick escreveu: >> Open a github issue for the problem; it won''t be addressed otherwise. >> >> On Tue, Feb 26, 2013 at 9:18 PM, Rodrigo Rosenfeld Rosas >> <rr.rosas@gmail.com <mailto:rr.rosas@gmail.com>> wrote: >> >> I think I''ve narrowed down the problem. For some reason this >> block isn''t executed when I run rake assets:precompile: >> >> https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L86 >> >> ActiveSupport.on_load(:action_view) do... >> >> 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 works. >> >> Then I''ve written something like this to fix the assets >> precompilation for my application: >> >> def fix_asset_precompiling >> 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 >> end >> end >> >> 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. >> >> - ActiveSupport.on_load(:action_view) do >> + begin >> >> But I don''t know what is the reason for the on_load hook, so I >> won''t change anything. I''d just like to let you know about this >> problem. This is a new bug and doesn''t exist on Rails 3. >> >> Best, >> Rodrigo. >> >> Em 26-02-2013 22:04, Rodrigo Rosenfeld Rosas escreveu: >>> 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, >>> Rodrigo. >>> >> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.