More views for more domains

Hello

I have more than one domain and i want to create different views for
each domain.

example i have:

  • domain_A,
  • domain_b

My question is how to create different views for each domain (each
domain has its
own view)?

Thanks

michal wrote:

Hello

I have more than one domain and i want to create different views for
each domain.

Just to clarify, are you saying the two domains will go to the same
app, with the same database, and do the same thing…but just look
different?

Or are you essentially talking about two different apps on the two
domains, but running on one server?

best,
jp

I’m saying about one app with one database and more than only one
domain.

Jeff P. wrote:

michal wrote:

Hello

I have more than one domain and i want to create different views for
each domain.

Just to clarify, are you saying the two domains will go to the same
app, with the same database, and do the same thing…but just look
different?

Or are you essentially talking about two different apps on the two
domains, but running on one server?

best,
jp

You’ll need to work with request.domain [and possibly the array of
request.subdomains] but I can’t tell if you’re talking about forcing
wholly
different layouts for each domain or merely having some controller
methods
use different views based on the domain. I can’t imagine a case for the
second but that’s what your question sounds like. Clarification??

RSL

I’m going out on a limb here but I’d use

layout “x” if request.domain == “domain-one.com
layout “y” if request.domain == “domain-two.com

for the layouts. (You may choose to use an if/else/end style.) For the
views
on each method you’ll have to call

def some_method

Code missing…

render :template => “blah/blah/blah” if request.domain ==
domain-one.com
render :template => “bleh/bleh/bleh” if request.domain ==
domain-two.com
end

or something. I would personally try to find a way to abstract that out
as a
filter on the actions. Something like

after_filter :map_to_view_by_domain

private

def map_to_view_by_domain
case request.domain
when “domain-one.com
render :template => “blah/blah/#{action_name}”
when “domain-two.com
render :template => “bleh/bleh/#{action_name}”
end
end

I’m not saying that’s valid code or anything but a rough idea. I think
it
should work but you’ll have to tool around with it. I’m currently logged
into Windows [dual boot] and don’t have access to Ruby/Rails. I hope
that
works. Or at least puts you on the right track.

RS: