How are you handling local associations with foreign objects?

21 views
Skip to first unread message

Tony Amoyal

unread,
Mar 21, 2011, 7:33:45 PM3/21/11
to service-oriented...@googlegroups.com
I have objects that live in a service such as an account.  However I want to store local has_and_belongs_to_many associations in the consuming application. 

For example an account may have many payment methods but I don't want that info in the service.  So I create an account_payment_methods table which contains those associations in the consuming application.  The account id in this case would be the id of the account in the service.  I've been playing around with this all afternoon and I'm finding it quite difficult to get Rails to understand this architecture.

 has_many : account_payment_methods
  has_many : payment_methods, :through => : account_payment_methods, :uniq => true, :foreign_key => :service_account_id

I would think @account.payment_methods would make the proper query here but it actually does nothing.  How are the readers of this book handling local associations to foreign objects?

Thanks!

-Tony

--
Tony C. Amoyal
www.tonyamoyal.com
www.frontierstrategygroup.com
www.frienduit.com
www.dailysongfix.com
www.betterhumanrace.com
(240) 417-3112
corga...@gmail.com
@tonyamoyal

"When the power of love overcomes the love of power, the world will know peace."
- Jimi Hendrix

Reply all
Reply to author
Forward
0 new messages