Hi,

I'm working with a many-to-many relationship between objects (Owner)
that own a shared resource (SharedResource), where the relationship
has an attribute that indicates the ordering of shared resources for a
particular owner (ordinal). My problem is that I can't seem to get an
order list of shared resources on the owner side.

Here's my setup:

    class Owner
      ...
      has n, :owner_shared_resources, :order => [:ordinal]
      has n, :shared_resources, :through => :owner_shared_resources
    end

    class OwnerSharedResource
      ...
      belongs_to :owner, :key => true
      belongs_to :shared_resource, :key => true
      property :ordinal, Integer
    end

    class SharedResource
      ...
      has n, :owners, :through => :owner_shared_resources
    end

Using `Owner.first.shared_resources` gives an unordered list. I have
tried this:

    class Owner
      ...
      has n, :shared_resource_ordinals, OwnerSharedResource, :order =>
[:ordinal]
      has n, :shared_resources, :through => :shared_resource_ordinals
    end

But to no avail.

I have ended up with:

    class Owner
      ...
      has n, :owner_shared_resources, :order => [:ordinal]
      def shared_resources
        self.owner_shared_resources.map {|x| x.shared_resource}
      end
    end

Which has obvious drawbacks.

What am I missing here?

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

Reply via email to