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 6804179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:26:04+00:00 2026-05-26T19:26:04+00:00

Currently I have a Rails 2.3 app that is a CMS serving over 100

  • 0

Currently I have a Rails 2.3 app that is a CMS serving over 100 websites. To encapsulate things a bit better each site has it’s own copy of a standard database structure (as defined in the schema.rb file). I currently use MySQL and when a request comes in to the server I check the hostname, look this up in a table in a central database, and then switch the connection to the appropriate database.

I’m looking to rewrite this application in Rails 3.1 and am also investigating using sqlite3 in production instead of MySQL as the individual databases are fairly small and would suit sqlite3. I’ve also used it in production on another project and it works well.

I’m looking for both tips on how to switch sqlite3 databases in-app, plus also how to detect the currently connected database within Rails for testing purposes.

  • 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-05-26T19:26:04+00:00Added an answer on May 26, 2026 at 7:26 pm

    For those that are contemplating this. Turns out it is much easier to implement this using PostgreSQL schema’s. It’s called multi-tenanting and with postgres you can have one database (defined in database.yml) and multiple schema’s within that database which are essentially just namespaces. Each schema has its own tables etc… and you can create, switch between and delete them on the fly. Make sure you use at least Rails 3.1.1 as prepared statements apparently wreaks havoc with database and schema switching. There are also some fixes in Rails master as of writing that address some minor issues with schemas.

    There is also a gem out there for multi-tenanting based on the above technology. It’s called Apartment but I just implemented things manually in my app as it was only about 20 lines of code to do what I wanted vs trusting a gem to do all the voodoo 🙂

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

Sidebar

Related Questions

I currently have a rails app and each user has a profile that has
Currently I have a Rails 3 app that subscribes new users up to MailChimp.
I have a rails 3 app that is currently using Devise for authentication. I
I have a rails app that is currently an affiliate site with my customer's
I have a private Rails app that I'm trying to install locally. It's currently
I have Rails 3.1 app that I'm currently hosting on Heroku. My problem is
I currently have a Rails 3.1 app that hosts multiple sites for several different
This is a bit complicated but here goes. I have a Rails app that
I'm currently writing a Rails app, and hit a somewhat strange quirk. I have
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a

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.