2011-10-21 36 views
4

我正在使用RABL来格式化Rails API的输出。我想下面的代码在rabl中渲染partials

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 

我的问题是,我不message.rabl渲染我的部分即comments.rabl。在rabl中渲染偏色的正确方法是什么?谢谢。

回答

10

你接近,这是一个有点混乱,但使用而不是局部扩展了这些情况:

child @comments do |t| 
    extends "user/comment" 
end 

,你应该是好去。请查看https://github.com/nesquena/rabl/issues/58以获取更详细的解释。

相关问题