Mongoid3 config with full uri

194 views
Skip to first unread message

Tal Atlas

unread,
May 3, 2012, 12:08:00 PM5/3/12
to Mongoid
I was wondering how to pass a full uri to a config file for the
current edge mongoid. I'm working on heroku and other than parsing or
manually reading out the config and putting it in the repo I can't
figure out how the new configs work.

In general a writeup somewhere on the new configs would be great, I
don't get at all what sessions are for.

Thanks

Durran Jordan

unread,
May 4, 2012, 2:20:35 AM5/4/12
to mon...@googlegroups.com
I'm going to release a new doc site for this with Mongoid 3, but if you want to see the writeup ahead of time you can look directly at the mongoid-side master branch here:

https://github.com/mongoid/mongoid-site/blob/master/source/mongoid/docs/installation.haml#L100

In a nutshell, a "session" is a database connection between the app and the db server. This can be a single connection, or many in the case of replica sets, but it's all encapsulated by a single session object. At minimum you just need to define 1 default session.

The reasoning for having the ability to have multiple sessions is that many users had asked for this - some apps, particularly SaaS ones can have a database per client on their own server. So now in Mongoid you can set this up and talk to whatever database you want in whatever database server you want at runtime.

https://github.com/mongoid/mongoid-site/blob/master/source/mongoid/docs/persistence.haml#L495

2012/5/3 Tal Atlas <swimmi...@gmail.com>

Hans Hasselberg

unread,
May 4, 2012, 4:21:42 AM5/4/12
to Mongoid
Hi Tal,

I have the same problem and I don't think its possible at the moment:
https://github.com/mongoid/mongoid/blob/master/lib/mongoid/sessions/factory.rb#L58.
It seems to me, that there is no uri option.

Cheers,
Hans

On May 4, 8:20 am, Durran Jordan <dur...@gmail.com> wrote:
> I'm going to release a new doc site for this with Mongoid 3, but if you
> want to see the writeup ahead of time you can look directly at the
> mongoid-side master branch here:
>
> https://github.com/mongoid/mongoid-site/blob/master/source/mongoid/do...
>
> In a nutshell, a "session" is a database connection between the app and the
> db server. This can be a single connection, or many in the case of replica
> sets, but it's all encapsulated by a single session object. At minimum you
> just need to define 1 default session.
>
> The reasoning for having the ability to have multiple sessions is that many
> users had asked for this - some apps, particularly SaaS ones can have a
> database per client on their own server. So now in Mongoid you can set this
> up and talk to whatever database you want in whatever database server you
> want at runtime.
>
> https://github.com/mongoid/mongoid-site/blob/master/source/mongoid/do...
>
> 2012/5/3 Tal Atlas <swimming.b...@gmail.com>

Tal Atlas

unread,
May 4, 2012, 1:42:13 PM5/4/12
to mon...@googlegroups.com
@Hans, This worked for me, even if it wasn't particularly elegant. https://gist.github.com/2588954
Reply all
Reply to author
Forward
0 new messages