Skip to content

Commit

Permalink
Merge pull request #8 from badlamer/master
Browse files Browse the repository at this point in the history
remove rails 5 deprecation
  • Loading branch information
ehsan-khaliki committed Jun 21, 2017
2 parents 4cbe4b5 + 66193c6 commit bc3eb77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/mongoid/embedded_errors.rb
Expand Up @@ -6,7 +6,8 @@ module Mongoid::EmbeddedErrors
def self.included(klass)
# make sure that the alias only happens once:
unless klass.instance_methods.include?(:errors_without_embedded_errors)
klass.alias_method_chain(:errors, :embedded_errors)
klass.send :alias_method, :errors_without_embedded_errors, :errors
klass.send :alias_method, :errors, :errors_with_embedded_errors
end
end

Expand All @@ -26,7 +27,7 @@ def errors_with_embedded_errors
rel.errors.messages.each do |k, v|
key = (metadata.relation == Mongoid::Relations::Embedded::Many ? "#{name}[#{i}].#{k}" : "#{name}.#{k}").to_sym
errs.delete(key)
errs[key] = v
errs.add key, v.flatten
errs[key].flatten!
end
end
Expand Down

0 comments on commit bc3eb77

Please sign in to comment.