FancyRoutes by TRED

Removing the cruft, bringing the HTTP method to the forefront and sporting a neat DRYing block syntax—FancyRoutes is a layer on top of the Rails routing system which provides an elegant API for mapping requests to your application's controllers and actions.


Here's an extract from one of Myles’ applications:

map.connect '/orders', :controller => 'orders', :action => 'index, :conditions => { :method => :get }

map.connect '/:slug/order', :controller => 'orders', :action => :show, :conditions => { :method => :get }
map.connect '/:slug/order', :controller => 'orders', :action => :create, :conditions => { :method => :post }

map.connect 'item_images/:image', :controller => 'item_images', :action => 'show', :conditions => { :method => :get }

The equivalent using fancyroutes:

get / 'orders' >> :orders > :index

with route / :slug / 'order' >> :orders do
  get > :show
  put > :update

get {'item_images' => :controller} / :image > :show

So fancy! You can see further examples and full documentation in the README.


Install the gem:

sudo gem install tred-fancyroutes

add the dependency in your environment.rb:

config.gem 'tred-fancyroutes'

and then use the FancyRoutes method in your routes.rb:

ActionController::Routing::Routes.draw do |map|
FancyRoutes(map) do
  # the
  # fanciest
  # routes
  # you
  # ever
  # did
  # see


The main source repository can be found at

The URL for the main git repository is:

git clone git://
Fork me on GitHub