Skip to content
Browse files

Fix pks scope

  • Loading branch information...
1 parent 7937aed commit e3b6f6cff25318973df1d0988b65df53a38e014d @rwdaigle rwdaigle committed Dec 11, 2009
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/utility_scopes/pks.rb
View
9 lib/utility_scopes/pks.rb
@@ -3,13 +3,18 @@ module Pks
def self.included(within)
- within.class_eval do
- named_scope :only_pks, :select => "`#{table_name}`.#{primary_key}"
+ within.class_eval do
extend ClassMethods
end
end
module ClassMethods
+
+ # Can't use named_scope b/c don't have access to table_name etc... yet
+ def only_pks
+ scoped(:select => "`#{table_name}`.#{primary_key}")
+ end
+
def pks
only_pks.collect(&:"#{primary_key}")
end

0 comments on commit e3b6f6c

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