From 8f8bfb60b866fff31da5e1b6d459b5d13718ee07 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 23 Aug 2016 21:39:21 +0200 Subject: [PATCH] Added mysql error regex to get human error message. --- app/controllers/application_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f2626333a..288b4971b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -546,6 +546,9 @@ class ApplicationController < ActionController::Base if error =~ /null value in column "(.+?)" violates not-null constraint/i data[:error_human] = "Attribute '#{$1}' required!" end + if error =~ /Field '(.+?)' doesn't have a default value/i + data[:error_human] = "Attribute '#{$1}' required!" + end if Rails.env.production? && !data[:error_human].empty? data[:error] = data[:error_human]