Rails routing to handle multiple domains on single application?

It's actually simpler in Rails 3, as per guides.rubyonrails.org/routing.html#adva....

It's actually simpler in Rails 3, as per guides.rubyonrails.org/routing.html#adva... 1) define a custom constraint class in lib/domain_constraint. Rb: class DomainConstraint def initialize(domain) @domains = domain. Flatten end def matches?(request) @domains.

Include? Request. Domain end end 2) use the class in your routes with the new block syntax constraints DomainConstraint.

New('mydomain. Com') do root :to => 'mydomain#index' end root :to => 'main#index' or the old-fashioned option syntax root :to => 'mydomain#index', :constraints => DomainConstraint. New('mydomain.Com').

Thanks for your answer... I had given up hope! But looking at this code, it appears that I need to anticipate the domain being used. I want to use any arbitrary domain.

But I've now discovered the answer (mostly), so I'll edit my question above. – Aaron Vegh Jan 20 at 14:15 Why would you declare the class in an initializer? Shouldn't that be in lib?

– ybakos Mar 16 at 3:22 Yep, it should be in lib. – Leonid Shevtsov Mar 25 at 14:57.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions