Ning
Ning

Reputation: 419

From Namespace to Subdomain?

what I want to do is to match the namespace route to subdomain route, for example in my routes.rb I have:

namespace :group do
  resources :groups
  resources :clubs
end

The current path of group index and each group is like:

lvh.me/group/groups
lvh.me/group/groups/1

But I don't like the URL here, I want to change the pages to:

group.lvh.me/groups
group.lvh.me/groups/1

As there will be several similar namespaces, is there a easier way for this? Many thanks!!

Upvotes: 8

Views: 1889

Answers (2)

msroot
msroot

Reputation: 837

constraints :subdomain => "group" do
 scope :module => "group", :as => "group" do
  resources :group
 end
end

Upvotes: 0

Jonathan Leung
Jonathan Leung

Reputation: 2061

constraints :subdomain => "admin" do
  scope :module => "admin", :as => "admin" do
    resources :players
  end
end

Similar Issue

Upvotes: 8

Related Questions