Philipp Kursawe
unread,Jan 17, 2012, 5:17:33 PM1/17/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DataMapper
I have these 2 models:
class Slot
include DataMapper::Resource
belongs_to :license
property :id, Serial
property :slot_nr, Integer
property :exp, DateTime
property :user_count, Integer
end
class SlotInfo
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
property :visible, Boolean, :default => lambda { |r, p|
default_visible(r, p) }
property :category, String
def name
SlotInfo.get(slot_nr).name
end
def visible?
SlotInfo.get(slot_nr).visible?
end
end
Is there a way to "merge" the name and visible properties from
SlotInfo into Slot via association?
So that I could omit the name and visible? methods and get these
values transparently through a join query when fetching a Slot from
the db?
Something like:
property :visible, :through => :slot_info, :key => :slot_nr
It works with the current code, but I cannot fetch all visible slots
via the license association at the moment:
"license.slots.visible" would be nice to have.