Rails: how to override stylesheet_path
I'm trying to override Rails' helper stylesheet_path
, but I haven't found a way how. I can't just open the module ActionView::Helpers::AssetTagHelper
and override it there because Rails won't pick up my new method.
I know this is probably because the module is mixing up, so how do I get around this?
a source to share
Are you doing this in a way that stylesheet_link_tag
leads to something different from the usual? If so, just override this in the helper :)
Alternatively, if you really want to override stylesheet_path
, you also need to override the alias, as curiously it is only accessible through its alias (in Rails 2.3.2). For example, I put this in environment.rb
and it worked:
module ActionView
module Helpers
module AssetTagHelper
def stylesheet_path(source)
"x"
end
alias_method :path_to_stylesheet, :stylesheet_path
end
end
end
I personally wouldn't go that route, but it should work for you if you need it :)
a source to share