diff options
author | Yuji Hanamura <yuji.developer@gmail.com> | 2018-03-09 16:04:56 +0900 |
---|---|---|
committer | Yuji Hanamura <yuji.developer@gmail.com> | 2018-03-09 16:04:56 +0900 |
commit | 6f4e66fefbcbf79351f41db0a75bf8aace43c1b7 (patch) | |
tree | f53275767fc47f048db0e0c4bb8ac9e88aa22fd4 /activerecord | |
parent | eec723f69ad0e2e957f9c9bca350a6e032c1b58f (diff) | |
download | rails-6f4e66fefbcbf79351f41db0a75bf8aace43c1b7.tar.gz rails-6f4e66fefbcbf79351f41db0a75bf8aace43c1b7.tar.bz2 rails-6f4e66fefbcbf79351f41db0a75bf8aace43c1b7.zip |
Add `delegate :pick, to: :all`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/querying.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb index 7c8f794910..15d3da682f 100644 --- a/activerecord/lib/active_record/querying.rb +++ b/activerecord/lib/active_record/querying.rb @@ -13,7 +13,7 @@ module ActiveRecord :where, :rewhere, :preload, :eager_load, :includes, :from, :lock, :readonly, :extending, :having, :create_with, :distinct, :references, :none, :unscope, :merge, to: :all delegate :count, :average, :minimum, :maximum, :sum, :calculate, to: :all - delegate :pluck, :ids, to: :all + delegate :pluck, :ids, :pick, to: :all # Executes a custom SQL query against your database and returns all the results. The results will # be returned as an array with columns requested encapsulated as attributes of the model you call diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 74228b2796..080d2a54bc 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -811,6 +811,11 @@ class CalculationsTest < ActiveRecord::TestCase assert_nil Topic.where("1=0").pick(:author_name, :author_email_address) end + def test_pick_delegate_to_all + cool_first = minivans(:cool_first) + assert_equal cool_first.color, Minivan.pick(:color) + end + def test_grouped_calculation_with_polymorphic_relation part = ShipPart.create!(name: "has trinket") part.trinkets.create! |