You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've trying create association links using Roar::JSON::JSONAPI but I can't reference represented method inside of the has_one block.
For instance:
classRequesterRepresenter < Roar::DecoratorincludeRoar::JSON::JSONAPItype:requesterhas_one:residence_addressdotype:addresslink:selfdo# I need way to get requester id here."http://example.com/requester/#{requester.id}/relationships/residence_address"endendproperty:id# ... other propertiesend
How I described, I would need some way to get requester.id inside of has_one. Anyway to do it?
I can't use represented as requester inside of has_one block, because when I used it, the represented is the instance of residence_address like example above.
The represented method refers to the currently rendered object, which is a residence_address in your case.
You can do represented.requester if that's what your data model allows. Alternatively, you can pass the requester as a :user_options to the block. Representable/Roar does not support accessing parent decorators right now (because that's data modelling and not representing). Let me think about that!
From @matheusca on November 19, 2015 22:15
Hi guys,
I've trying create association links using
Roar::JSON::JSONAPI
but I can't referencerepresented
method inside of thehas_one
block.For instance:
How I described, I would need some way to get
requester.id
inside ofhas_one
. Anyway to do it?Copied from original issue: trailblazer/roar#168
The text was updated successfully, but these errors were encountered: