glue block is fired with glued object and not parent object #374

Closed
elado opened this Issue Dec 9, 2012 · 3 comments

Comments

Projects
None yet
5 participants
@elado

elado commented Dec 9, 2012

Docs say:

object @user
glue(@post) {|user| attribute :title if user.active? }

But looks like the object passed to the block is the glued object, the post, and not the user. In collection it seems impossible to access the current iterated object.

It would be great to have them both in the iteration.

@databyte

This comment has been minimized.

Show comment Hide comment
@databyte

databyte Dec 20, 2012

Collaborator

Try root_object.

Collaborator

databyte commented Dec 20, 2012

Try root_object.

@beedub

This comment has been minimized.

Show comment Hide comment
@beedub

beedub Apr 5, 2013

@databyte can you elaborate?

beedub commented Apr 5, 2013

@databyte can you elaborate?

@andrewhubbs

This comment has been minimized.

Show comment Hide comment
@andrewhubbs

andrewhubbs Apr 8, 2013

The short answer is that when iterating through a collection, the instance variables like @post and @user are not set as you might think. root_object is a method in the Rabl Engine that gives you access to the currently set object. If you look at engine.rb you'll see what I'm talking about. The question of why those variables aren't setup if going to be better answered by someone that know Rabl better than me.

The short answer is that when iterating through a collection, the instance variables like @post and @user are not set as you might think. root_object is a method in the Rabl Engine that gives you access to the currently set object. If you look at engine.rb you'll see what I'm talking about. The question of why those variables aren't setup if going to be better answered by someone that know Rabl better than me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment