Trying to get an value from a DataMapper join table and association?

Without changing any of your code, you should be able to do: mix_clip = clip. Mix_clips. First(:mix => mix, :clip => clip) to get at the join record associated with your specific mix and clip resources Currently, there's a bug in DM that makes it kinda unreliable to do the following without any additional measures: mix_clip = clip.

Mix_clips. Get(mix. Id, clip.Id) This is because DM forgets the order in which relationships have been defined, and thus cannot currently know reliably in which order the get method should accept the primary key components You can work around this by defining the foreign key properties explicitly in your join model, like so (note that you still have to declare the relationships explicitly, of course): class MixClip include DataMapper::Resource property :id, Serial property :order, Integer property :mix_id, Integer, :key => true property :clip_id, Integer, :key => true belongs_to :mix belongs_to :clip end This will make sure that DM knows that get accepts the primary key as (mix_id, clip_id) so you're now able to call mix_clip = clip.

Mix_clips. Get(mix.Id, clip. Id) A reason for wanting to do that is that calls to get take the identity map into account, which, based on your access characteristics, might be able to yield better performance.

Without changing any of your code, you should be able to do: mix_clip = clip. Mix_clips. First(:mix => mix, :clip => clip) to get at the join record associated with your specific mix and clip resources.

Currently, there's a bug in DM that makes it kinda unreliable to do the following without any additional measures: mix_clip = clip. Mix_clips. Get(mix.Id, clip.

Id) This is because DM forgets the order in which relationships have been defined, and thus cannot currently know reliably in which order the . Get method should accept the primary key components. You can work around this by defining the foreign key properties explicitly in your join model, like so (note that you still have to declare the relationships explicitly, of course): class MixClip include DataMapper::Resource property :id, Serial property :order, Integer property :mix_id, Integer, :key => true property :clip_id, Integer, :key => true belongs_to :mix belongs_to :clip end This will make sure that DM knows that .

Get accepts the primary key as (mix_id, clip_id) so you're now able to call mix_clip = clip. Mix_clips. Get(mix.

Id, clip. Id) A reason for wanting to do that is that calls to . Get take the identity map into account, which, based on your access characteristics, might be able to yield better performance.

MixClip joins the Mix/Clip tables and includes an extra property to describe the clip (order). I would like to know if it's possible to have a clip object and be able to reference the current clip in the context it was loaded in. Is there a way to get the MixClip that is associated with that specific Clip?

It was loaded through join between the table, so I would think there would be a way to do it. I know I can just get all the mix->mix->clips-> and and drill down, but was wondering if I would be able to go back up levels... it would be simpler. For those wondering, I'm trying to use this because dm-serializer doesn't have full support for nested associations when returning json/xml and I'd like to be able to just define a method that returns the data.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions