From bf77c84095bcaab795079bc40c2b33b782535d56 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Wed, 5 Mar 2014 00:42:05 +0100 Subject: [PATCH] BugFix: email-in on categories wasn't null-ed properly Causing a problem if two categories got saved with an empty string because the corresponding Database constraint on the index would complain about dublicate values --- app/controllers/categories_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index ed2a9fcbb34..32284c03c20 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -60,6 +60,10 @@ class CategoriesController < ApplicationController if category_params[:position] category_params[:position] == 'default' ? cat.use_default_position : cat.move_to(category_params[:position].to_i) end + if category_params.key? :email_in and category_params[:email_in].length == 0 + # properly null the value so the database constrain doesn't catch us + category_params[:email_in] = nil + end category_params.delete(:position) cat.update_attributes(category_params) }