lgs / mongoid_taggable_with_context

A tagging plugin for Mongoid that allows for custom tagging along dynamic contexts with real-time aggregation (pre-aggregated).
http://rubygems.org/gems/mongoid_taggable_with_context
MIT License
19 stars 20 forks source link

undefined method `tags_with_weight' for #15

Closed parthisrm closed 10 years ago

parthisrm commented 10 years ago

Getting this error undefined method `tags_with_weight' for

I am using Mongoid::TaggableWithContext::AggregationStrategy::RealTime strategy

tags method works as expected. using Rails 3.2.13, Mongoid 3.0.23.

The Model / document where I am using tags is embedded in another document.

class Note include Mongoid::Document include Mongoid::Timestamps include Mongoid::TaggableWithContext
include Mongoid::TaggableWithContext::AggregationStrategy::RealTime

taggable

field :name, type: String field :content, type: String

embedded_in :root, :inverse_of => :notes end

lgs commented 10 years ago

Did you included an aggregation strategy ? ... something like:

class Post
  include Mongoid::Document
  include Mongoid::TaggableWithContext
  # automatically adds real time aggregations to all tag contexts
  include Mongoid::TaggableWithContext::AggregationStrategy::RealTime
  # alternatively for map-reduce
  # include Mongoid::TaggableWithContext::AggregationStrategy::MapReduce
  field :title
  field :content
  taggable
  taggable :skills, separator: ','
  taggable :ints, as: interests
end

When you include an aggregation strategy, your document also gains a few extra methods to retrieve aggregation data. In the case of previous example the following methods are included:

Post.tags
Post.tags_with_weight
Post.interests
Post.interests_with_weight
Post.skills
Post.skills_with_weight