我正在使用RABL格式化Rails API的输出。我尝试了下面的代码
message.rabl:
object @message
attributes :id,:description,:created_at,:created_by_user_id
child @comments do |t|
partial("user/comment", :object => @comments)
endcomments.rabl:
object @comments
attributes :comment_body我的问题是我的message.rabl没有渲染我的部分,也就是comments.rabl。在rabl中渲染部分的正确方法是什么?谢谢。
发布于 2011-10-22 01:23:35
您已经很接近了,这有点令人困惑,但在这些情况下使用extends而不是partial:
child @comments do |t|
extends "user/comment"
end你应该可以走了。有关更详细的解释,请查看此https://github.com/nesquena/rabl/issues/58。
https://stackoverflow.com/questions/7847843
复制相似问题