Subdomain Routing plugin

Plugin details

Rails plugin providing support for routing subdomains.

Repositorygit://github.com/henrik/subdomain_routing.git Author Henrik Nyh Tags Subdomain, route LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install git://github.com/henrik/subdomain_routing.git

Routes
=========
This plugin allows you to do e.g.

map.subdomain(:blog) do |blog|
  blog.root :controller => 'blog/index'
end


instead of

map.with_options(:conditions => { :subdomain => "blog" }, :name_prefix => "blog_") do |blog|
  blog.root :controller => 'blog/index'
end


The :name_prefix means that the named routes will be blog_root etc.

Generating URLs
================
Makes Rails URL generation add subdomains when necessary.

If the :name_prefix for the route begins with one of the subdomains defined with Mapper#subdomain (above), e.g. blog_, the corresponding subdomain is used if necessary. "Necessary" means either that the user requested a full URL (e.g. blog_root_url) or that the link points to another subdomain than the current one.

So if you are at blog.example.com:

blog_root_path  # => "/"
blog_root_url   # => "http://blog.example.com/"
other_root_path # => "http://other.example.com/"
other_root_url  # => "http://other.example.com/"

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: hardway, 5 months ago