Commonly overlooked usage of named routes

Posted by – March 30, 2008

Given a route :

ActionController::Routing::Routes.draw do |map|
  map.foo "foo/:first/:second", :controller => "foo", :action => "something"
end

Obviously you can pass in :first and :second via:

foo_path(:first => "the first param", :second => "the second param")

However, for a more concise call, you can accomplish the same via:

foo_path("the first param", "the second param")

It’s not explicitly documented, but you end up doing the same thing with nested resource paths

0 Comments on Commonly overlooked usage of named routes

Closed