Skip to content

Commit

Permalink
Fix pks scope
Browse files Browse the repository at this point in the history
  • Loading branch information
rwdaigle committed Dec 11, 2009
1 parent 7937aed commit e3b6f6c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/utility_scopes/pks.rb
Expand Up @@ -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
Expand Down

0 comments on commit e3b6f6c

Please sign in to comment.