How can I specify an actual session in store_in?

23 views
Skip to first unread message

Daniel Doubrovkine

unread,
Jan 20, 2015, 12:14:25 PM1/20/15
to mon...@googlegroups.com
I am generating a dynamic class via meta-programming that includes Mongoid::Document. I need it to get data from a mongoid session, however I don't have access to the session name.

Is there a way to do something like store_in: ... but on an actual session, not a session name?

Thanks,

Arthur Neves

unread,
Jan 20, 2015, 12:50:37 PM1/20/15
to mon...@googlegroups.com
mongo_session is a method on the class https://github.com/mongoid/mongoid/blob/master/lib/mongoid/sessions.rb#L104-L108 , you can override that method and return a actual session object.

If thats what you are looking for.

--

---
You received this message because you are subscribed to the Google Groups "Mongoid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoid+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Arthur Nogueira Neves
Follow me @arthurnn

Daniel Doubrovkine

unread,
Jan 20, 2015, 3:59:32 PM1/20/15
to mon...@googlegroups.com
I ended up doing just that in https://github.com/dblock/mongoid_collection_snapshot/commit/58cd9da82b7d011f3ad3822250596301e297d6b8.

Adding cattr_accessor :mongo_session, then assigning it. Maybe assigning the mongo_session should be a feature in mongoid?

Arthur Neves

unread,
Jan 20, 2015, 5:50:37 PM1/20/15
to mon...@googlegroups.com
Not sure if Mongoid should allow people injecting the session object.
Reply all
Reply to author
Forward
0 new messages