If I have many domains and one rails application, how can I redirect to conrollers by domain? Ex. "domain.com" go to controller "/com", "domain.net" go to controller "/net" and "other.org" go to "/other" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 17, 2007, at 2:42 PM, Ki Lo wrote:> If I have many domains and one rails application, how can I > redirect to > conrollers by domain? > > Ex. "domain.com" go to controller "/com", "domain.net" go to > controller > "/net" and "other.org" go to "/other"You can extract the domain type from the request object (use request.domain and split on the period to get the last element) I probably wouldn''t write different controllers if the differences are minor. If there is the need for multiple controllers, there''s probably still one controller you initially interface to which can change what it does based on the domain type (that is you pass the domain type to the controller and let it make conditional decisions -- which might be factory pattern to launch a controller you describe above). You might find some useful thoughts here: http://www.railsdev.ws/blog/10/using-subdomains-in-rails-apps/ -- def gw acts_as_n00b writes_at(www.railsdev.ws) end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 18 Dec 2007, at 11:29, Greg Willits wrote:>> If I have many domains and one rails application, how can I >> redirect to >> conrollers by domain? >> >> Ex. "domain.com" go to controller "/com", "domain.net" go to >> controller >> "/net" and "other.org" go to "/other" > > > You can extract the domain type from the request object (use > request.domain and split on the period to get the last element) > > I probably wouldn''t write different controllers if the differences > are minor. If there is the need for multiple controllers, there''s > probably still one controller you initially interface to which can > change what it does based on the domain type (that is you pass the > domain type to the controller and let it make conditional decisions > -- which might be factory pattern to launch a controller you > describe > above). > > You might find some useful thoughts here: > http://www.railsdev.ws/blog/10/using-subdomains-in-rails-apps/The account_location plugin provides nice helpers for these kinds of situations. However, a more appropriate solution in this case would be to use apache''s rewrite functions to rewrite the request to point to the correct controller. Saves you some conditioning and all the problems that may arise from it in your rails app. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---