Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix cache busting on Hassle stylesheets.
  • Loading branch information
jasoncodes committed Dec 11, 2010
1 parent b2ce7d0 commit 74f9a95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/hassle.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'
22 changes: 22 additions & 0 deletions lib/hassle/action_view.rb
@@ -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
Copy link

@mag mag commented on 74f9a95 Mar 11, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@mag mag commented on 74f9a95 Mar 14, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - works like a charm.

Please sign in to comment.