From ed3bbbe177d2f92df0917328f5de62e8ba8911e9 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 29 Jul 2015 17:50:59 -0700 Subject: [PATCH] fixes #1412: When creating or deleting favorites through the API, return some form of response --- app/controllers/favorites_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index 09e0ebf65..6322510e3 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -30,6 +30,13 @@ class FavoritesController < ApplicationController redirect_to(mobile_post_path(@post)) end format.js + format.json do + if @post + render :json => {:success => true}.to_json + else + render :json => {:success => false, :reason => @error_msg}.to_json, :status => 422 + end + end end end @@ -42,6 +49,9 @@ class FavoritesController < ApplicationController redirect_to(mobile_post_path(@post)) end format.js + format.json do + render :json => {:success => true}.to_json + end end end end