From d75071bac9ea360732cc71d07c3868bb36b3ff38 Mon Sep 17 00:00:00 2001 From: Marco Colli Date: Sat, 20 Dec 2014 19:09:33 +0100 Subject: [PATCH] Solve #5348 --- app/controllers/likes_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index c5750bee5..8822af378 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -11,7 +11,13 @@ class LikesController < ApplicationController :json def create - @like = current_user.like!(target) if target rescue ActiveRecord::RecordInvalid + begin + @like = if target + current_user.like!(target) + end + rescue ActiveRecord::RecordInvalid => e + # do nothing + end if @like respond_to do |format|