I'm making a JSON API and want to serialize a recipe
record from my database. In the JSON response, I want to include the output of @recipe.is_favorited_by?(current_user)
along with some of the recipe
's attributes.
I saw from the docs that I could call: render json: @recipe, methods: :is_favorited_by?
- but I'm not sure how to pass in current_user as an argument.
What call would I need to make in order to include the results of @recipe.is_favorited_by?(current_user
) in the response?