Ruby on rails 用rabl表示分部
我正在使用RABL格式化Rails API的输出。我尝试了以下代码 message.rabl:Ruby on rails 用rabl表示分部,ruby-on-rails,api,partials,rabl,Ruby On Rails,Api,Partials,Rabl,我正在使用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) end 评论.rabl: object @comments attributes :comme
object @message
attributes :id,:description,:created_at,:created_by_user_id
child @comments do |t|
partial("user/comment", :object => @comments)
end
评论.rabl:
object @comments
attributes :comment_body
我的问题是,我的message.rabl没有呈现我的部分,即comments.rabl。在rabl中呈现分部词的正确方法是什么。多谢各位 您很接近,这有点令人困惑,但对于这些情况,请使用extends而不是partial:
child @comments do |t|
extends "user/comment"
end
你应该可以走了。检查此项以获得更详细的解释