未验证 提交 9c6f348d 编写于 作者: R Rafael Mendonça França

Merge pull request #25849 from suginoy/fix_merge_in_scope

Fix the calling `merge` method at first in a scope
* Support calling the method `merge` in `scope`'s lambda.
*Yasuhiro Sugino*
* Fixes multi-parameter attributes conversion with invalid params.
*Hiroyuki Ishii*
......
......@@ -9,7 +9,7 @@ module Querying
delegate :find_each, :find_in_batches, :in_batches, to: :all
delegate :select, :group, :order, :except, :reorder, :limit, :offset, :joins, :left_joins, :left_outer_joins, :or,
:where, :rewhere, :preload, :eager_load, :includes, :from, :lock, :readonly,
:having, :create_with, :uniq, :distinct, :references, :none, :unscope, to: :all
:having, :create_with, :uniq, :distinct, :references, :none, :unscope, :merge, to: :all
delegate :count, :average, :minimum, :maximum, :sum, :calculate, to: :all
delegate :pluck, :ids, to: :all
......
......@@ -46,6 +46,13 @@ def test_delegates_finds_and_calculations_to_the_base_class
assert_equal Topic.average(:replies_count), Topic.base.average(:replies_count)
end
def test_calling_merge_at_first_in_scope
Topic.class_eval do
scope :calling_merge_at_first_in_scope, Proc.new { merge(Topic.replied) }
end
assert_equal Topic.calling_merge_at_first_in_scope.to_a, Topic.replied.to_a
end
def test_method_missing_priority_when_delegating
klazz = Class.new(ActiveRecord::Base) do
self.table_name = "topics"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册