0

When customers is created in my app ruby on rails,I want to create database for each customers without break/closing my exiting/running application database.When particular customer is login then I want to CRUD operations on both databases. My app Database name is myapp. E.g when customer 1 is created in myapp I want create One database for customer_1. when customer 2 is created in myapp I want create One database for customer_2.

When customer 1 is login in myapp , when he does any crud operations then I want save all data in Myapp database as well as customer_1 database.

3 Answers 3

2

try sequel

Sequel is a simple, flexible, and powerful SQL database access toolkit for Ruby.

Sequel provides thread safety, connection pooling and a concise DSL for constructing SQL queries and table schemas.

i think this tool can help you create many database set on you app

Sign up to request clarification or add additional context in comments.

4 Comments

I have one myapp database , I don't want break exiting app.This is used for reporting purpose
@ShankarKamble Using Sequel is better as you can create databases on the fly too. You can specify a complete SQL query too using it.
@JunaidKirkire is there any way create database in postgresql using sequel
@ShankarKamble if you have connection to database you can create.DB = Sequel.connect('postgres://user:password@host:port/') and DB.run "CREATE DATABASE customer_1 bla bla bla" read documentations
0

You can try to use establish_connection (using before_filter in application_controller) http://www.runtime-era.com/2012/11/dynamic-activerecord-database.html

Comments

0

first make another label and put there all setting of databasee in database.yml then in respected model from where you want to connect different database create two different methods and assign their database connection by establish_connection(database.yml files label name here such as "development") and another method put another db name, which location you want to switch database then call these methods.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.