diff options
author | Yehuda Katz <wycats@gmail.com> | 2012-04-30 10:09:26 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2012-04-30 10:09:26 -0700 |
commit | 69c2307a7d48a3ab64a161fbf1d3fd20675e3f38 (patch) | |
tree | 8e0fcac9f09ca6ea0d59288f65b6542d293ae1c5 /activerecord/lib | |
parent | c435feb4044f6c62bb188c459c3be5d81cc77b07 (diff) | |
parent | 93076168c4d2209e007a32abc7142cc23782d56a (diff) | |
download | rails-69c2307a7d48a3ab64a161fbf1d3fd20675e3f38.tar.gz rails-69c2307a7d48a3ab64a161fbf1d3fd20675e3f38.tar.bz2 rails-69c2307a7d48a3ab64a161fbf1d3fd20675e3f38.zip |
Merge pull request #6091 from twinturbo/add-ids
Add ActiveRecord::Base#ids - Close #5812
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index db894c8aa9..f388b75c05 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -139,6 +139,16 @@ module ActiveRecord end end + # Pluck all the ID's for the relation using the table's primary key + # + # Examples: + # + # Person.ids # SELECT people.id FROM people + # Person.joins(:companies).ids # SELECT people.id FROM PEOPLE INNER JOIN companies ON companies.person_id = people.id + def ids + pluck primary_key + end + private def perform_calculation(operation, column_name, options = {}) |