Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for rails4 #1

Open
wants to merge 3 commits into
base: support_for_rails4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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? }
Expand Down
3 changes: 2 additions & 1 deletion lib/validates_timeliness/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down