I have setup Mongoid the way it is suggested on the Mongoid.org
website, which creates a connection to the database using the Rails
initializer. I'm wondering if something similar to
establish_connection in ActiveRecord could be used to create the
connection when a request comes in on a subdomain?
Anyone have any thoughts...
I do require to change database on the fly and per model.
My app supports users with subdomain accounts. The app will have db
for users, roles, permissions etc. And each account can have multiple
subdomains. Each subdomain will have it's own database.
Ideally it would be nice to do the following:
class ApplicationController < ActionController::Base
@subdomain.database = current_subdomain + "-dev"
end
class User
include Mongoid::Document
Mongoid.database = "global"
end
class Page
include Mongoid::Document
Mongoid.database = @subdomain.database
end
I'm currently using MongoMapper and this is working fine.
I'm keen on trying Mongoid, but without this it's a no go.
On Mar 8, 10:20 pm, Durran Jordan <dur...@gmail.com> wrote:
> I dont have an elegant way of doing this at the moment, you'd have to do a
> little bit of hackery and switch out the master or slaves in the config on
> the fly at the moment - but I'll have a thought about a good way to handle
> this and add a story for it... Are you looking to change databases on the
> fly, or just configure it at the model level?
>
On Mar 8, 8:20 am, Durran Jordan <dur...@gmail.com> wrote:
> I dont have an elegant way of doing this at the moment, you'd have to do a
> little bit of hackery and switch out the master or slaves in the config on
> the fly at the moment - but I'll have a thought about a good way to handle
> this and add a story for it... Are you looking to change databases on the
> fly, or just configure it at the model level?
>