I’ve got a class that has a property that is the same name as the symbol for another class it has a “belongs_to” relationship with.
class Ledger include DataMapper::Resource property :id,Serial property :posted_on,Integer property :memorandum,String property :amount,Integer property :account_id,Integer property :entry_id,Integer property :entry_amount_id,Integer property :fiscal_period_id,Integer property :currency_id,Integer belongs_to :account belongs_to :entry belongs_to :entry_amount, :class_name => 'Amount', :child_key => [ :entry_amount_id ] end
Looks like the docs at datamapper.org are a little out of sync with the version of datamapper I’m using, as they specify that something like this will work:
class Post include DataMapper::Resource belongs_to :author, :model => 'User', :child_key => [ :post_id ] end
I scoped out my cloned copy of the dm-core code and noticed the conspicuous options:
OPTIONS = [ :class_name, :child_key, :parent_key, :min, :max, :through ]
and guessed “:class_name” might work. Indeed it does! Nice. I have to remark that working with datamapper is intellectually rewarding.