From 579fd2c04f729ff37bcea37603e4d647d33e8998 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Thu, 28 Sep 2017 15:37:31 +0300 Subject: [PATCH] Fix bug when no talks are selected --- app/controllers/talk_preferences_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/talk_preferences_controller.rb b/app/controllers/talk_preferences_controller.rb index 61fafe2..f9b8727 100644 --- a/app/controllers/talk_preferences_controller.rb +++ b/app/controllers/talk_preferences_controller.rb @@ -29,12 +29,12 @@ class TalkPreferencesController < ApplicationController @talk_preference.transaction do @talk_preference.selected_talks.destroy_all - if @talk_preference.update talk_preference_params + if params[:talk_preference].blank? || @talk_preference.update(talk_preference_params) render json: { - update_url: talk_preference_url(@talk_preference), - hashed_uid: @talk_preference.hashed_unique_id, - uid: @talk_preference.id - } + update_url: talk_preference_url(@talk_preference), + hashed_uid: @talk_preference.hashed_unique_id, + uid: @talk_preference.id + } else head :unprocessable_entity raise ActiveRecord::Rollback