Abhi Abhi - 1 year ago 87
Ruby Question

How to pass object into rabl partial?

I need to create a rabl partial, where I need access to an object. For Eg:-

# app/views/posts/index.rabl
collection @posts

node(false) { |post| partial('posts/show', :object => :post)}

Inside show.rabl

# app/views/posts/index.rabl
object @post

node(:details) do
{:id => @post.id}

Gives me, undefined method id for nil class. What am I doing wrong? Even the documentation gives the same steps.

Answer Source

Have you tried this?


Hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download