I've been trying to override Rails' stylesheet_path
helper, but I haven't found a way how. I can't just open the ActionView::Helpers::AssetTagHelper
module and override it there, because Rails won't pick up my new method.
I know it's probably because the module gets mixed in, so how do I get around that?
Are you doing this so that stylesheet_link_tag
will result in something different from normal? If so, just override that in a helper :)
Alternatively, if you really want to override stylesheet_path
, you need to also redefine the alias, as, curiously, it's only accessed via 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 this route but it should work for you if you need it :)