How to pass object into rabl partial?

632 views Asked by At

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}
end

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

1

There are 1 answers

3
Rajdeep Singh On BEST ANSWER

Have you tried this?

locals[:object].id

Hope this helps!