Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8072169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:55:54+00:00 2026-06-05T13:55:54+00:00

I have a Rails 2 app that serves multiple domains. That is, http://domainA.com and

  • 0

I have a Rails 2 app that serves multiple domains. That is, http://domainA.com and http://domainB.com are both served by the same Rails app. When I launch these manually, I specify which site I want to see by passing a site variable: site=domainB ruby script/server.

I’d like to use Pow so that I can access both sites via http://domainA.myapp.dev and http://domainB.myapp.dev (I’d also be happy with http://domainA.dev and http://domainB.dev if that’s easier).

I can do this manually by adding export site="domainB" to my .powrc file, and editing that by hand (then doing touch tmp/restart.txt) each time I want to switch sites … I’d prefer something a bit more automatic, though. I’m thinking something like the equivalent of subdomain == domainA ? export site="domainA" : export site="domainB" within the .powrc file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:55:56+00:00Added an answer on June 5, 2026 at 1:55 pm

    I figured out how to do this, and wrote a blog post about it here. This is the gist of how it’s done…

    I configured my before_filter to get the domain that’s being accessed, and to use that throughout the Rails app. If the site is being accessed via the standard Rails app, it won’t have a domain (it would just be localhost). In that case, the before_filter looks for the site variable being passed at the command line (and if that’s not passed, then it uses a default site).

    def set_site
      if RAILS_ENV == "development"
        session[:site] = case request.domain
          when "domainA.dev" then "domainA"
          when "domainB.dev" then "domainB"
          else ENV['site'] || "domainA"
        end
      else session[:site].blank?
        if RAILS_ENV == "staging"
          session[:site] = case request.subdomains.last # *.yourstagingdomain.com
            when "domainA" then "domainA"
            when "domainB" then "domainB"
          end
        elsif RAILS_ENV == "production"
          session[:site] = case request.domain
            when "domainA.com" then "domainA"
            when "domainB.com" then "domainB"
            else "domainA"
          end
        else
          session[:site] = "domainA" # default
        end
      end
      if @site.nil?
        @site ||= Site.find_by_name(session[:site])
      end
    end
    

    The whole thing is actually done within Rails itself, and the only involvement that Pow has is that there has to be a symlink for each site being served by the Rails app.

    The symlinks must also match the request.domain that’s being checked in the before_filter. So, in this example there would be two symlinks – domainA and domainB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails app that includes pg_search and queue_classic gems. Both of these
I currently have a Rails 3.1 app that hosts multiple sites for several different
I have a single Rails 2.2.2 app that I want to 'share' with multiple
I have a rails app that serves some APIs to an iPhone application. I
I have a rail app that serves multiple domain_name and is deployed by nginx
I have a rails app that I'm moving to another server and I figure
I have a rails app that requires multi-table inheritance for which I am using
I have a rails app that was working fine with sqlite but upon switching
I have a rails app that runs on Heroku using their standard postgres database
I have a rails app that I am deploying via capistrano. The app deploys

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.