Guest User

Untitled

a guest
Jun 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
  2. index 78b3507..9fb64b5 100644
  3. --- a/activerecord/lib/active_record/base.rb
  4. +++ b/activerecord/lib/active_record/base.rb
  5. @@ -961,9 +961,12 @@ module ActiveRecord #:nodoc:
  6. attribute_names = match.attribute_names
  7. super unless all_attributes_exists?(attribute_names)
  8. if match.finder?
  9. - options = arguments.extract_options!
  10. - relation = options.any? ? construct_finder_arel(options, current_scoped_methods) : scoped
  11. - relation.send :find_by_attributes, match, attribute_names, *arguments
  12. + self.class.send :define_method, method_id do |*args|
  13. + options = args.extract_options!
  14. + relation = options.any? ? construct_finder_arel(options, current_scoped_methods) : scoped
  15. + relation.send :find_by_attributes, match, attribute_names, *args
  16. + end
  17. + send(method_id, *arguments)
  18. elsif match.instantiator?
  19. scoped.send :find_or_instantiator_by_attributes, match, attribute_names, *arguments, &block
  20. end
Add Comment
Please, Sign In to add comment