Agile Web Development

Build it. Launch it. Love it.

Request Routing

Plugin that allows you to define routing requirements that test methods/properties of the request object such as subdomain, domain, port. You can test them either against a value or with a Regexp (assuming the method returns a string).

In routes.rb you can specify use the :requirements hash with request properties:

map.connect '', :controller => 'main', :requirements => { :subdomain => 'www' }

You can also, of course, use the requirements hash in map.with_options calls.

The allowed properties are:

    :subdomain  (only checks the first subdomain)
    :domain 
    :method (a symbol)
    :port (a number)
    :remote_ip 
    :content_type (content type of the post body)
    :accepts 
    :request_uri (the entire request uri)
    :protocol (either http:// or https://)

Vitals

Repository http://svn.danwebb.net/external/rails/plugins/request_routing/trunk/
License Rails' (MIT)
Rating (28 votes)
Owner Dan Webb
Created 18 May 2006

Comments

  • Avatar
    Eric Campbell
    11 August 2007

    This works great, except I had to use

    :conditions => {:subdomain => 'www'}

    instead of

    :requirements => {:subdomain => 'www'}

  • Elliot
    10 May 2008

    The url doesn't work anymore?

Add a comment