diff --git a/lib/validates_timeliness/extensions/multiparameter_attribute.rb b/lib/validates_timeliness/extensions/multiparameter_attribute.rb index b1278521..23160354 100644 --- a/lib/validates_timeliness/extensions/multiparameter_attribute.rb +++ b/lib/validates_timeliness/extensions/multiparameter_attribute.rb @@ -42,8 +42,8 @@ def validate_multiparameter_date_values(set_values) end def read_value_with_timeliness - @column = object.class.reflect_on_aggregation(name.to_sym) || object.column_for_attribute(name) - klass = column.klass + @cast_type = object.type_for_attribute(name) + klass = cast_type.klass set_values = values.is_a?(Hash) ? values.to_a.sort_by(&:first).map(&:last) : values if set_values.empty? || set_values.all?{ |v| v.nil? } diff --git a/lib/validates_timeliness/validator.rb b/lib/validates_timeliness/validator.rb index 806dbe2b..289f86ec 100644 --- a/lib/validates_timeliness/validator.rb +++ b/lib/validates_timeliness/validator.rb @@ -43,9 +43,10 @@ def initialize(options) @restrictions_to_check = RESTRICTIONS.keys & options.keys super + setup_timeliness_validated_attributes(options[:class]) if options[:class] end - def setup(model) + def setup_timeliness_validated_attributes(model) if model.respond_to?(:timeliness_validated_attributes) model.timeliness_validated_attributes ||= [] model.timeliness_validated_attributes |= @attributes