Skip to content

Commit

Permalink
item might be nil - we need to take that into account
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Sep 10, 2008
1 parent 3fdfa9c commit c53064b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/acts_as_recommendable.rb
Expand Up @@ -49,6 +49,7 @@ def self.aar_dataset(force = false)
@aar_items_with_scores ||= begin
self.__send__(self.aar_options[:through]).collect {|ui|
item = ui.__send__(self.aar_options[:on_singular])
next unless item
if self.aar_options[:score]
score = ui.__send__(self.aar_options[:score]).to_f
score = 1.0 if !score or score <= 0
Expand All @@ -59,7 +60,7 @@ def item.aar_score; @aar_score; end
def item.aar_score=(d); @aar_score = d; end
item.aar_score = score
item
}.inject({}) {|h, item| h[item.id] = item; h }
}.compact.inject({}) {|h, item| h[item.id] = item; h }
end
end

Expand Down

0 comments on commit c53064b

Please sign in to comment.