Are there any best practices for designing multitenant applications using rails? Would I want to run 10 instances of the same application, or one instance of an application that can handle 10 tenants? What if I was making a forum, for example, and people could come and sign up and create their own forums. Are there any good ways for segregating all the topics in one forum from all the topics in another? All the users in one forum from all users in another? I realize this question is rather vague, and the real reason I''m asking is that people are saying good things about using RESTful resources and things in rails applications, but it doesn''t seem like it would handle multitenant applications very well. I would certainly want a different posts/get route for each tenant, for example. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Brocoum wrote:> Are there any best practices for designing multitenant applications > using rails? Would I want to run 10 instances of the same application, > or one instance of an application that can handle 10 tenants? > > What if I was making a forum, for example, and people could come and > sign up and create their own forums. Are there any good ways for > segregating all the topics in one forum from all the topics in > another? All the users in one forum from all users in another? > > I realize this question is rather vague, and the real reason I''m > asking is that people are saying good things about using RESTful > resources and things in rails applications, but it doesn''t seem like > it would handle multitenant applications very well. I would certainly > want a different posts/get route for each tenant, for example.No problems. Free your mind and abstract one level higher. class Forum belongs_to :user has_many :topics end class Topic has_many :threads end map.resources :forums do |forums| forums.resources :topics do |topics| topics.resources :threads .. end end end Cheers. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Typically people building multi-tenant applications will scope the data based on an Account model (or something similar) which is loaded at request time by fetching a record based on the request host. That is, each account has its own subdomain, so you know which data to load based on that. In your case, a Forum could have a domain field, and you have a before filter that loads the forum based on request.host, and then displays posts scoped to that forum: e.g. @forum.posts.find(:all) in the index action. It just so happens that I have code that implements this very model, along with all the code needed to implement recurring billing, should you be building something you want people to pay you to use. :) Check it out at http://railskits.com/saas/ -- it''s not free, but it would come in very handy for you. ---- Benjamin Curtis http://catchthebest.com/ - Team-powered recruiting http://www.bencurtis.com/ - Personal blog On Apr 21, 11:32 am, Stedwick <philip.broc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are there any best practices for designing multitenant applications > using rails? Would I want to run 10 instances of the same application, > or one instance of an application that can handle 10 tenants? > > What if I was making a forum, for example, and people could come and > sign up and create their own forums. Are there any good ways for > segregating all the topics in one forum from all the topics in > another? All the users in one forum from all users in another? > > I realize this question is rather vague, and the real reason I''m > asking is that people are saying good things about using RESTful > resources and things in rails applications, but it doesn''t seem like > it would handle multitenant applications very well. I would certainly > want a different posts/get route for each tenant, for example.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---