Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix pks scope

  • Loading branch information...
commit e3b6f6cff25318973df1d0988b65df53a38e014d 1 parent 7937aed
Ryan Daigle rwdaigle authored

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. +7 2 lib/utility_scopes/pks.rb
9 lib/utility_scopes/pks.rb
@@ -3,13 +3,18 @@ module Pks
3 3
4 4 def self.included(within)
5 5
6   - within.class_eval do
7   - named_scope :only_pks, :select => "`#{table_name}`.#{primary_key}"
  6 + within.class_eval do
8 7 extend ClassMethods
9 8 end
10 9 end
11 10
12 11 module ClassMethods
  12 +
  13 + # Can't use named_scope b/c don't have access to table_name etc... yet
  14 + def only_pks
  15 + scoped(:select => "`#{table_name}`.#{primary_key}")
  16 + end
  17 +
13 18 def pks
14 19 only_pks.collect(&:"#{primary_key}")
15 20 end

0 comments on commit e3b6f6c

Please sign in to comment.
Something went wrong with that request. Please try again.