Ticket #341 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Add support for namespace

Reported by: ma..@paulbarry.com Assigned to:
Priority: major Milestone: The Future
Component: Merb Keywords:
Cc:

Description

Add support for a namespace option in routing, so that you can have different resources for different contexts. So for example if you declare your routing like this:

  r.match(:host => /^admin\b/).to(:namespace => 'admin') do |admin|
    admin.resources :articles
  end

  #r.resources :articles, :namespace => 'admin'
  # RESTful routes
  r.resources :articles

That would make:

  • http://foo.com/articles => Articles controller
  • http://admin.foo.com/articles => Admin::Articles controller

And it would also create named routes for articles and admin_articles. Then, you can change the first line to:

  r.match('/admin').to(:namespace => 'admin') do |admin|

And you would now have:

  • http://foo.com/articles => Articles controller
  • http://foo.com/admin/articles => Admin::Articles controller

And all of the links throughout the app would work, assuming you used the correct named routed.

Attachments

namespace.diff (7.1 kB) - added by ma..@paulbarry.com on 12/02/07 05:59:24.
namespace.2.diff (8.7 kB) - added by ma..@paulbarry.com on 12/03/07 07:56:04.
namespace.3.diff (8.6 kB) - added by ma..@paulbarry.com on 12/03/07 08:27:28.
Includes spec for '/admin/foo'

Change History

12/02/07 05:59:24 changed by ma..@paulbarry.com

  • attachment namespace.diff added.

12/03/07 07:20:51 changed by iv..@gweezlebur.com

I'd like to see some specs on the /admin/foo case, but otherwise this looks good.

12/03/07 07:56:04 changed by ma..@paulbarry.com

  • attachment namespace.2.diff added.

12/03/07 07:57:13 changed by ma..@paulbarry.com

I just added a few more specs for testing namespace when not used in the context of resources, is that what you were looking for?

12/03/07 08:10:43 changed by iv..@gweezlebur.com

No, I meant for when you're using route namespacing (/admin) instead of domain namespacing.

12/03/07 08:27:28 changed by ma..@paulbarry.com

  • attachment namespace.3.diff added.

Includes spec for '/admin/foo'

12/14/07 00:20:27 changed by e.@brainspl.at

  • status changed from new to closed.
  • resolution set to fixed.

(In [1104]) add :namespace option to routes. closes #341 [ma..@paulbarry.com]