【发布时间】:2016-05-18 09:49:44
【问题描述】:
我正在制作 JSON API 并希望从我的数据库中序列化 recipe 记录。在 JSON 响应中,我想包含 @recipe.is_favorited_by?(current_user) 的输出以及 recipe 的一些属性。
我从the docs 看到我可以调用:render json: @recipe, methods: :is_favorited_by? - 但我不确定如何将 current_user 作为参数传递。
我需要打什么电话才能在响应中包含@recipe.is_favorited_by?(current_user) 的结果?
【问题讨论】:
标签: ruby ruby-on-rails-4 active-model-serializers