30 Aug 2008, 00:33
Generic-user-small

Robby Dhillon (1 post)

Your tutorial on giving users their own unique subdomain or domain is great but lacks one thing:

Request routing in such application. How do you tell rails which controller to use based on URL that is request? Let’s say my product site has the following URL “www.example.com/features”:#, now, how can I prevent my users from exploiting the system in case they visit “user1.example.com/features”:#??? Also, can an application like such have a root mapping for the controller? ie ~~~ map.root :controller => “site” ~~~ …??? Also, how would I go about allowing the users to ONLY login from their subdomain or domain specific site and not the product site, ie users should only be able to login by either visiting “user1.example.com/login”:# or “user1.com/login”:# and not via “www.example.com/login”:# …also, how would I go about have my product site at “example.com”:# instead of “www.example.com”:#…these are some of my unanswered questions and would help to have them explained in bit more detail. Thank you. Btw, I have already checked out ‘Request Routing’ & ‘Tricky Routes’ plugins but for some reason they both do not play well with Rails 2.1.0. An alternative solution would be helpful without the use of a plugin.

Thanks!

14 Dec 2009, 18:52
Myself_small_pragsmall

Anatoly Mikhaylov (6 posts)

http://github.com/mbleigh/subdomain-fu Examples: users_path(:subdomain => “fun”) users_url(:subdomain => false) map.with_options :conditions => {:subdomain => ‘admin’} do |admin| admin.resources :posts admin.resources :users end

SubdomainFu provides a modern implementation of subdomain handling in Rails. It takes aspects from account_location, request_routing, and other snippets found around the web and combines them to provide a single, simple solution for subdomain-based route and url management.

  You must be logged in to comment