Permalink
Browse files

Fix cache busting on Hassle stylesheets.

  • Loading branch information...
jasoncodes committed Dec 11, 2010
1 parent b2ce7d0 commit 74f9a95ae6273bdc200a46c8bd503fa7704f98a7
Showing with 24 additions and 1 deletion.
  1. +2 −1 lib/hassle.rb
  2. +22 −0 lib/hassle/action_view.rb
@@ -1,2 +1,3 @@
require File.dirname(__FILE__) + '/hassle/hassle'
require File.dirname(__FILE__) + '/hassle/railtie'
require File.dirname(__FILE__) + '/hassle/action_view'
require File.dirname(__FILE__) + '/hassle/railtie'
@@ -0,0 +1,22 @@
# fix cache busting for Hassle stylesheets
# try the original path ("public/") and if not found, try "tmp/".
require 'action_view/helpers/asset_tag_helper'
module ActionView::Helpers::AssetTagHelper
private
def rails_asset_id_with_tmp_path(source)
asset_id = rails_asset_id_without_tmp_path source
if asset_id.blank?
org_dir = config.assets_dir
begin
config.assets_dir = Rails.root + 'tmp/hassle'
asset_id = rails_asset_id_without_tmp_path source
ensure
config.assets_dir = org_dir
end
end
asset_id
end
alias_method_chain :rails_asset_id, :tmp_path
end

3 comments on commit 74f9a95

@mag

This comment has been minimized.

mag replied Mar 11, 2011

Hi!

I'd really like to use your fork since it seems to fix the cache-busting problem, but this monkey patch is causing my app to blow up (see below). Seems like some kind of load-order thing. I reverted to your previous commit, and took this monkey-patch and put it in a Rails initializer, and it worked fine.

$ rake
(in /Users/pivotal/workspace/myproject)
rake aborted!
uninitialized constant ActionView::Helpers::TagHelper
/Users/pivotal/workspace/myproject/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
noe:~/workspace/myproject (master)$ rake --trace
(in /Users/pivotal/workspace/myproject)
rake aborted!
uninitialized constant ActionView::Helpers::TagHelper
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/date_helper.rb:584:in `<class:DateTimeSelector>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/date_helper.rb:582:in `<module:Helpers>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/date_helper.rb:7:in `<module:ActionView>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/date_helper.rb:6:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/form_helper.rb:2:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/active_model_helper.rb:1:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers.rb:38:in `<module:Helpers>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers.rb:4:in `<module:ActionView>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers.rb:3:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/tag_helper.rb:6:in `<module:ActionView>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/tag_helper.rb:4:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/javascript_helper.rb:1:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/url_helper.rb:1:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:3:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/bundler/gems/hassle-a61495da1957/lib/hassle/action_view.rb:4:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/bundler/gems/hassle-a61495da1957/lib/hassle.rb:2:in `<top (required)>'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
/Users/pivotal/.rvm/gems/ruby-1.9.2-p180@myproject/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
/Users/pivotal/workspace/myproject/config/application.rb:7:in `<top (required)>'
@jasoncodes

This comment has been minimized.

Owner

jasoncodes replied Mar 12, 2011

Hi Mike,

Thanks for letting me know about this issue. I have reproduced it in a clean Rails 3.0.5 app and have added a couple additional requires in 2b17153 to fix the issue.

Jason

@mag

This comment has been minimized.

mag replied Mar 14, 2011

Thanks - works like a charm.

Please sign in to comment.