Closed ethicalhack3r closed 9 years ago
@ethicalhack3r, try root_object
, it's works for me.
Thanks!
I think my problem here is that I was trying to use the same view for both a single object (called from a controller) and a collection of objects (called from elsewhere in my codebase).
I was doing this from elsewhere in my codebase:
Rabl::Renderer.new('api/v2/wordpresses/show', Wordpress.all, view_path: 'app/views', format: 'json').render
I solved my problem by passing a single object to the view rather than a collection. Calling Rabl::Renderer
for each object and then creating an Array/hash/whatever from that.
Wordpress.all.each do |wordpress|
Rabl::Renderer.new('api/v2/wordpresses/show', wordpress, view_path: 'app/views', format: 'json').render
end
In the following rabl view, how do I access the @plugin.id if @plugin is a collection?
show.rabl: