Skip to content

Instantly share code, notes, and snippets.

@learnist
Created January 29, 2010 21:36
Show Gist options
  • Save learnist/290167 to your computer and use it in GitHub Desktop.
Save learnist/290167 to your computer and use it in GitHub Desktop.
route_options = {:controller => 'toys', :action => 'index', :owner_id => 'toy_owner'}
# initialize Mapper with the current RouteSet
mapper = ActionController::Routing::RouteSet::Mapper.new(ActionController::Routing::Routes)
# create a new named_route
new_named_route = mapper.named_route('rubber_duck', 'rubber_duck', route_options)
# add to current RouteSet
ActionController::Routing::Routes.routes.insert(0, new_named_route)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment