I am using the to_json
method on an object, and trying to get the :methods
argument to work. I have a method on my model (Drop) called is_favorited_by_user?
. This method takes an argument of the current_user
, and then checks to see if the drop is favorited by the user. How can I pass this argument through the to_json
method.
render :json => @drops.to_json(:methods => :is_favorited_by_user?(current_user))