Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Saving tag weight aggregations as integers

  • Loading branch information...
commit 8120d12e61a44897178a55d6040901ea66922395 1 parent 48af60e
@andresf authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/mongoid/taggable.rb
View
4 lib/mongoid/taggable.rb
@@ -169,7 +169,7 @@ def define_tag_field_accessors(name)
# retrieve the list of tags with weight(count), this is useful for
# creating tag clouds
define_method "#{name}_with_weight" do
- db.collection(tags_aggregation_collection).find.to_a.map{ |r| [r["_id"], r["value"]] }
+ db.collection(tags_aggregation_collection).find.to_a.map{ |r| [r["_id"], r["value"].to_i] }
end
end
end
@@ -185,7 +185,7 @@ def aggregate_tags!
result = self.class.aggregate_tags!(options.clone)
if options[:save_as]
- result = result["results"].to_a.map { |r| [r["_id"], r["value"]] }
+ result = result["results"].to_a.map { |r| [r["_id"], r["value"].to_i] }
options[:save_as][:object].send(:"#{options[:save_as][:attribute].to_s}=",
result)
options[:save_as][:object].save
Please sign in to comment.
Something went wrong with that request. Please try again.