2011-10-21 33 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以獲取更詳細的解釋。

相關問題