Logout, multiple orgs, rematerializing

15 views
Skip to first unread message

the_cobra

unread,
Oct 26, 2011, 1:54:33 PM10/26/11
to activesa...@googlegroups.com
The databasedotcom gem is so nice to use that I'm finding all sorts of things to do with it. One of those things involves logging into several orgs in succession, and I'm having a little bit of trouble there and hope someone has a tip for me. I find that if I authenticate to an org and materialize an SObject, say Account, that if I materialize Account again using another Databasedotcom::Client that Account still points at the first org.

The steps might be like this:

1. create Databasedotcom::Client, authenticate against org 1
2. materialize Account
3. create another client, authenticate it against org 2
4. materialize Account with client 2 ??
5. Account.first is the first account from org 1

Is there a way to deal with this using modules via sobject_module that I haven't figured out yet? Or perhaps a way to unauthenticate the client and/or rematerialize an SObject class?

Thanks
The Cobra

Danny Burkes

unread,
Oct 26, 2011, 4:24:38 PM10/26/11
to activesa...@googlegroups.com
You need to scope the materialized classes to a module specific to each client- that way, they  termwon't conflict with each other.

module Client1Module; end
module Client2Module; end

client1.sobject_module = Client1Module
client1.materialize("Account") #=> Client1Module::Account

client2.sobject_module = Client2Module
client2.materialize("Account") #=> Client2Module::Account

- D


--
You received this message because you are subscribed to the Google Groups "ActiveSalesforce" group.
To view this discussion on the web visit https://groups.google.com/d/msg/activesalesforce/-/wQTuYR1-7NAJ.
To post to this group, send email to activesa...@googlegroups.com.
To unsubscribe from this group, send email to activesalesfor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/activesalesforce?hl=en.

the_cobra

unread,
Oct 26, 2011, 6:17:51 PM10/26/11
to activesa...@googlegroups.com
Ah, I get it now. I saw that mentioned in the docs and earlier discussions, but at first I couldn't see how to use it in my case. 

The list of org logins is coming from Account records in another salesforce org and things got pretty postmodern there for a sec. Using eval to create a module for each of those accounts is working for me.

Thanks and great gem!


Danny Burkes

unread,
Oct 27, 2011, 4:53:32 AM10/27/11
to activesa...@googlegroups.com
No need for eval, by the way-

    mod = Module.new
    Object.const_set("MyNewModule", mod) #=> MyNewModule
    client.sobject_module = MyNewModule

- D

--
You received this message because you are subscribed to the Google Groups "ActiveSalesforce" group.
To view this discussion on the web visit https://groups.google.com/d/msg/activesalesforce/-/rTBQ1jUEoF4J.

the_cobra

unread,
Oct 28, 2011, 5:32:52 PM10/28/11
to activesa...@googlegroups.com
Didn't know about that way, thanks for the tip!
Reply all
Reply to author
Forward
0 new messages