Question

I am developing a application using Rails 3.0.1 which will be deployed on two differents domains (same server, same project). The users have differents plans, so I should show differents styles, images and redirect to differents urls depending the user plan. The first problem is easy because I could have a instance variable setted in ApplicationController depending the user plan. However my problem is with links and routes helpers.

How could use routes helpers and depending the user plan return www.domain1.com or www.domain2.com?

Please excuse my limited English, Corrections are welcome.

Thanks in advance

Was it helpful?

Solution

You should be fine using the named routes, regardless of how you use them, since it will take your current domain into account. For example:

on www.domain1.com

<%= link_to "Home", root_url %> # uses 'http://www.domain1.com'
<%= link_to "Home", root_path %> # uses '/', which will go to http://www.domain1.com/

on www.domain2.com

<%= link_to "Home", root_url %> # uses 'http://www.domain2.com'
<%= link_to "Home", root_path %> # uses '/', which will go to http://www.domain2.com/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top