Skip to content

Commit

Permalink
FIXED: sunspot rails to work with non-standard AR primary key, ie if …
Browse files Browse the repository at this point in the history
…use the set_primary_key on a model
  • Loading branch information
John Eberly authored and Mat Brown committed Mar 10, 2010
1 parent 8c813c2 commit 8c19eed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sunspot_rails/lib/sunspot/rails/adapters.rb
Expand Up @@ -47,7 +47,7 @@ def select=(value)
# ActiveRecord::Base:: ActiveRecord model
#
def load(id)
@clazz.find_by_id(id.to_i, options_for_find)
@clazz.send("find_by_#{@clazz.primary_key}", id.to_i, options_for_find)
end

#
Expand All @@ -62,7 +62,7 @@ def load(id)
# Array:: Collection of ActiveRecord models
#
def load_all(ids)
@clazz.find_all_by_id(ids.map { |id| id.to_i }, options_for_find)
@clazz.send("find_all_by_#{@clazz.primary_key}", ids.map { |id| id.to_i }, options_for_find)
end

private
Expand Down

0 comments on commit 8c19eed

Please sign in to comment.