Browse files

Changing one_to_many method to reflect current sequel method of doing…

… polymorphism
  • Loading branch information...
1 parent b783cab commit e10168f9a152c5fecb490aede7545978a0eb777a @saimonmoore committed Nov 26, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/sequel/plugins/polymorphic.rb
View
4 lib/sequel/plugins/polymorphic.rb
@@ -23,9 +23,9 @@ def many_to_one(*args, &block)
self.class_eval %{
associate(:many_to_one, :#{able}, :reciprocal=>:#{plural_model},
:dataset=>(proc { klass = #{able}_type.constantize; klass.filter(klass.primary_key=>#{able}_id) }),
- :eager_loader=>(proc do |key_hash, #{plural_model}, associations|
+ :eager_loader=>(proc do |eo|
id_map = {}
- #{plural_model}.each do |#{singular_model}|
+ eo[:rows].each do |#{singular_model}|
#{singular_model}.associations[:#{able}] = nil;
((id_map[#{singular_model}.#{able}_type] ||= {})[#{singular_model}.#{able}_id] ||= []) << #{singular_model}
end

0 comments on commit e10168f

Please sign in to comment.