Rails Database Configuration

I’m building an application in which I’d like groups of users to have
their
own dedicated MySQL/SQLite database for the application.

How can I configure Rails so that ActiveRecord uses that group’s
dedicated
database from the start?


Joshua S. Martin

Joshua M. wrote:

I’m building an application in which I’d like groups of users to have
their
own dedicated MySQL/SQLite database for the application.

How can I configure Rails so that ActiveRecord uses that group’s
dedicated
database from the start?

That question comes up fairly frequently on this list. The usual
answer: that’s a bad idea – don’t do it. You shouldn’t need to have
separate databases for groups.

If you can explain more about why you think you want to do this, we can
offer alternative suggestions.


Joshua S. Martin

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

I see. It’s not the fact that I want the data to be separated that made
me
consider multiple DBs, it’s the fact that I want the user to be able to
make
a full SQL or CSV backup of his account that can be restored from within
my
application or into another database.

Perhaps the better question is, how would I make an SQL or CSV export
(within Rails) of only certain data in the database (the key here being
only
certain data) ?

On Tue, May 18, 2010 at 1:38 PM, Marnen Laibow-Koser
[email protected]wrote:

answer: that’s a bad idea – don’t do it. You shouldn’t need to have

“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Joshua S. Martin

CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the attorney
client or other legal privileges, and or proprietary non public
information.
If you are not an intended recipient of this message or an authorized
assistant to an intended recipient, please notify the sender by replying
to
this message and then delete it from your system. Use, dissemination,
distribution, or reproduction of this message and or any of its
attachments
(if any) by unintended recipients is not authorized and may be unlawful.

Joshua M. wrote:

I see. It’s not the fact that I want the data to be separated that made
me
consider multiple DBs, it’s the fact that I want the user to be able to
make
a full SQL or CSV backup of his account that can be restored from within
my
application or into another database.

Perhaps the better question is, how would I make an SQL or CSV export
(within Rails) of only certain data in the database (the key here being
only
certain data) ?

You can easily generate CSV or SQL just like any other view template.

However, for mass SQL backups, I think I’d advise just having Rails call
the database’s own dump script.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]