Improved error handling. If string in invalid charset (e. g. on binary fields), .blank? will fail (call it later).
This commit is contained in:
parent
228a0df54a
commit
57c6a25357
1 changed files with 2 additions and 1 deletions
|
@ -18,7 +18,6 @@ module ApplicationModel::ChecksAttributeValuesAndLength
|
|||
def check_attribute_values_and_length
|
||||
columns = self.class.columns_hash
|
||||
attributes.each do |name, value|
|
||||
next if value.blank?
|
||||
next if !value.instance_of?(String)
|
||||
column = columns[name]
|
||||
next if !column
|
||||
|
@ -27,6 +26,8 @@ module ApplicationModel::ChecksAttributeValuesAndLength
|
|||
self[name].force_encoding('BINARY')
|
||||
end
|
||||
|
||||
next if value.blank?
|
||||
|
||||
# strip null byte chars (postgresql will complain about it)
|
||||
if column.type == :text
|
||||
if Rails.application.config.db_null_byte == false
|
||||
|
|
Loading…
Reference in a new issue