Related records via Master-Detail?

19 views
Skip to first unread message

Mason Jones

unread,
Nov 8, 2011, 1:02:53 AM11/8/11
to ActiveSalesforce
Hi, I've been playing with the gem and it's doing very nicely. I did
notice one convenience that would be very helpful, and I wanted to
make sure I'm not overlooking something since I haven't exercised the
gem too much yet.

In SFDC we have a custom object, call it "Entry__c", which is related
to another custom object, call it "Related__c". So looking at Entry__c
in the admin, I see:

Field Label: Related ID
API Name: Related_ID__c
Date Type: Master-Detail(Related)

Now, I realize that the naming is not good, but that predates me so...
The relation works fine in SFDC, so each instance of Entry__c is tied
to a Related instance. Looking at an instance of Entry__c via the
databasedotcom gem, I see something like:

@Related_ID__c="a0640000004QgG1ETY"

And of course I can do a find for that Id and it's happy. But
obviously I'd like to be able to say "my_entry.Related" and access the
object, which given that it has the Master-Detail relationship should
be feasible, yes?

If the answer is related to getting the field named correctly, bummer
but I understand.

Thx all...

Danny Burkes

unread,
Nov 8, 2011, 1:06:39 AM11/8/11
to activesa...@googlegroups.com
It is certainly possible to implement, but automatic association loading isn't currently a feature of the gem.  We are accepting pull requests, though! :-D

- D


--
You received this message because you are subscribed to the Google Groups "ActiveSalesforce" group.
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.


Mason Jones

unread,
Nov 8, 2011, 1:08:44 AM11/8/11
to activesa...@googlegroups.com
That was a quick reply, thanks! ;-)

I was reading one of the commits on the 1.2 version, and it looked
like the auto associations were working (e.g. contact.Account
example), but I might have misinterpreted?

Danny Burkes

unread,
Nov 8, 2011, 1:12:19 AM11/8/11
to activesa...@googlegroups.com
They work if you specifically issue a query that selects fields from a related object, but they don't work in the general case where you just want to access a related object through an existing instance of some other class.  

- D

Mason Jones

unread,
Nov 8, 2011, 1:28:26 AM11/8/11
to activesa...@googlegroups.com
Ah, gotcha, thanks for the clarification. Have you considered an
ActiveRecord-style approach to mimic behavior like belongs_to and so
on? I'm not sure off the top of my head how it might be done in
conjunction with the materialize() usage, but it might be more clear
to specify the relationships explicitly in a similar way. I'll give it
some thought...

Danny Burkes

unread,
Nov 8, 2011, 1:31:41 AM11/8/11
to activesa...@googlegroups.com
Sure, I think ActiveRecord-style associations would be nice, I just don't have time to implement them at present.  Thus the plea for pull requests :-)

- D
Reply all
Reply to author
Forward
0 new messages