Re: [Rails] one database multiple sites

31 views
Skip to first unread message

Walter Lee Davis

unread,
Mar 13, 2017, 7:51:03 PM3/13/17
to rubyonra...@googlegroups.com
There are a number of different ways you can manage this. One popular approach is to use the Apartment gem to create what is known as the "multi-tenant" database pattern. See if that term gets you closer to what your are looking for.

One database (or at least one schema) per site is the usual method, so maybe say a little more about why you feel that you need to have the same database for multiple sites. What makes these sites special, or what makes the number of databases constrained?

Walter

> On Mar 13, 2017, at 6:30 PM, fugee ohu <fuge...@gmail.com> wrote:
>
> i have the idea to use the same database for multiple sites but i guess each site needs it's own database in addition? Anyone can guide me?
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/54a73f7c-f8c5-4474-92b5-80a4ca884146%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

fugee ohu

unread,
Mar 13, 2017, 8:23:05 PM3/13/17
to Ruby on Rails: Talk
I want each app/site to have it's own database but i also wanna let them update a commonly shared database in addition to each apps own database

fugee ohu

unread,
Mar 13, 2017, 8:28:06 PM3/13/17
to Ruby on Rails: Talk


On Monday, March 13, 2017 at 7:51:03 PM UTC-4, Walter Lee Davis wrote:
table has
The users "role" is the condition that determines which database the user will access  although in this case it's not roles it's just a field in the users table that says which database the user will be using

Colin Law

unread,
Mar 14, 2017, 4:47:15 AM3/14/17
to Ruby on Rails: Talk
Why use multiple databases? Why not put it all in one database?

Colin

go...@solutionize.in

unread,
Jul 10, 2017, 11:50:05 PM7/10/17
to Ruby on Rails: Talk
The way I architect such Apps is by using centralized scope based authorization. It keeps the App clean and avoid bugs like dev forgot to scope the records in controller - controller can ONLY operate on records that are permitted for the current user. If somebody tries to access resource outside of what they are permitted, :not_found is returned rather than :unauthorized - works well for security and user experience.

It has worked well for most of my Apps including complex ERP solutions. Based on project requirements, you may want to use independent schemas (pg), though it might be overkill in lot of use cases.
Reply all
Reply to author
Forward
0 new messages