Skip to content

Instantly share code, notes, and snippets.

@tpope
Created January 31, 2011 03:02
Show Gist options
  • Save tpope/803573 to your computer and use it in GitHub Desktop.
Save tpope/803573 to your computer and use it in GitHub Desktop.
ActionDispatch::Routing::PolymorphicRoutes.module_eval do
def polymorphic_url_with_hierarchy(record, options={})
record = record.hierarchy if record.respond_to?(:hierarchy)
polymorphic_url_without_hierarchy(record, options)
end
alias_method_chain :polymorphic_url, :hierarchy
end
ActionView::Helpers::FormHelper.module_eval do
def form_for_with_hierarchy(object, *args, &block)
object = object.hierarchy if object.respond_to?(:hierarchy)
form_for_without_hierarchy(object, *args, &block)
end
alias_method_chain :form_for, :hierarchy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment