Re: [DataMapper] many-to-many in legacy db

2012-09-30 Thread Roman Dzvinkovsky
Thanks you!

2012/9/24 Zhi-Qiang Lei zhiqiang@gmail.com:
 En taro Tassadar,

 You can write it in this way.

 class ContactFund
   include DataMapper::Resource

   def self.default_repository_name
 :vm_legacy
   end

   storage_names[:vm_legacy] = 'contactfunds'

   belongs_to :fund
   belongs_to :contact

   property :fund_id, String, key: true, field: fundID
   property :contact_id, String, key: true, field: contactID
 end


 On Sep 24, 2012, at 8:17 AM, romand wrote:

 En taro Tassadar,

 I use DM to access legacy db with many-to-many relationship between Fund and
 Contact models, through ContactFund -- table with 2 columns: 'fundID' and
 'contactID'.
 Here is my model: http://pastebin.com/KtQcdRyq
 But child_key is ignored for some reason, so DM looks for 'fund_id' instead
 of 'fundID': http://pastebin.com/yBCT9NNg

 How do I write ContactFund correctly?

 Thanks in advance,
 Roman.

 --
 You received this message because you are subscribed to the Google Groups
 DataMapper group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/datamapper/-/l9OB8C38670J.
 To post to this group, send email to datamapper@googlegroups.com.
 To unsubscribe from this group, send email to
 datamapper+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/datamapper?hl=en.



 Best regards,
 Zhi-Qiang Lei
 zhiqiang@gmail.com

 --
 You received this message because you are subscribed to the Google Groups
 DataMapper group.
 To post to this group, send email to datamapper@googlegroups.com.
 To unsubscribe from this group, send email to
 datamapper+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/datamapper?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
DataMapper group.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.



Re: [DataMapper] many-to-many in legacy db

2012-09-24 Thread Zhi-Qiang Lei
En taro Tassadar,

You can write it in this way.

class ContactFund
  include DataMapper::Resource

  def self.default_repository_name
:vm_legacy
  end

  storage_names[:vm_legacy] = 'contactfunds'

  belongs_to :fund
  belongs_to :contact

  property :fund_id, String, key: true, field: fundID
  property :contact_id, String, key: true, field: contactID
end


On Sep 24, 2012, at 8:17 AM, romand wrote:

 En taro Tassadar,
 
 I use DM to access legacy db with many-to-many relationship between Fund and 
 Contact models, through ContactFund -- table with 2 columns: 'fundID' and 
 'contactID'. 
 Here is my model: http://pastebin.com/KtQcdRyq
 But child_key is ignored for some reason, so DM looks for 'fund_id' instead 
 of 'fundID': http://pastebin.com/yBCT9NNg
 
 How do I write ContactFund correctly?
 
 Thanks in advance,
 Roman.
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 DataMapper group.
 To view this discussion on the web visit 
 https://groups.google.com/d/msg/datamapper/-/l9OB8C38670J.
 To post to this group, send email to datamapper@googlegroups.com.
 To unsubscribe from this group, send email to 
 datamapper+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/datamapper?hl=en.


Best regards,
Zhi-Qiang Lei
zhiqiang@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
DataMapper group.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.