4

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.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
nilkash
  • 7,408
  • 32
  • 99
  • 176

1 Answers1

10

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.

Nathan
  • 1,381
  • 20
  • 43
  • 58