Is it possible to dynamically change the path from which controllers are used? Ryan Bates showed how to change the view_paths here: http://railscasts.com/episodes/269-template-inheritance
I’m making a CMS where a user can create a site and enter their own subdomain. I’d like “/” to point to “public#welcome” if there’s no subdomain, but if there is a subdomain, I want it to point to “sites/public#welcome”.
I’m using Rails 3.1 if that makes any difference.
I figured it out:
Now when a user visits “/” Sites::PublicController will be used if a subdomain exists, but just PublicController if no subdomain exits. Adding
scope :module => "sites" do...endkeeps my routes file simplistic and manageable.