I’m brand new to Ruby and Rails, but I’ve read a lot of the requisite
tutorials and feel pretty comfortable with most of it. I’ve been
developing sites in PHP for the better part of a decade, so please bear
in mind that I’m still trying to break myself out of “thinking” in PHP.
The last remaining problem I can’t seem to find any answer to – maybe
I’m just not searching correctly – is how to control the template
system. Let me give you an example of what I want to do.
For this site, we will be accepting clients with their own domain name.
All of these domain names will be pointed to the same directory on our
server, where the client application lives. I need to be able to use all
the same logic – the controllers, right? – but load a different
template for each domain, so that each looks like its own site. I have
already determined how to get the domain name being accessed, and can
look up which theme the site is using in my database. My confusion comes
in what to do next, and how to organize this.
In PHP, I would have a /themes/ directory with a bunch of different
subdirectories, each containing a set of templates. When the client’s
site first loads, I would do a query to find out which theme path they
are supposed to be using. Let’s say it’s /themes/silver. I would set
that as a session variable and use it whenever loading a template file.
How should I approach this in RoR?
Thanks for your patience and help! Remember, I haven’t actually
implemented anything in RoR yet, so speak slowly.