module ActiveRecord::DatabaseValidations::StringTruncator::ClassMethods
Public Instance Methods
truncate_string(field)
click to toggle source
# File lib/active_record/validations/string_truncator.rb, line 30 def truncate_string(field) method_name = :"truncate_#{field}_at_database_limit" define_method(method_name) do return unless self.changes.key?(field.to_s) self[field] = truncate_value_to_field_limit(field, self[field]) return # to make sure the callback chain doesn't halt end return method_name end
truncate_to_field_limit(field)
click to toggle source
Calls superclass method
# File lib/active_record/validations/string_truncator.rb, line 24 def truncate_to_field_limit(field) define_method(:"#{field}=") do |value| super(truncate_value_to_field_limit(field, value)) end end