I am using RABL to format the output of a Rails API. I tried following code
message.rabl:
object @message
attributes :id,:description,:created_at,:created_by_user_id
child @comments do |t|
partial("user/comment", :object => @comments)
end
comments.rabl:
object @comments
attributes :comment_body
My problem is that my message.rabl not rendering my partial i.e. comments.rabl . What is the proper way to render partials in rabl. Thank you.
You were close, and it is a bit confusing but use extends instead of partial for these cases:
child @comments do |t|
extends "user/comment"
end
and you should be good to go. Check this https://github.com/nesquena/rabl/issues/58 for a more detailed explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With