Skip to content

Instantly share code, notes, and snippets.

@khelll
Created January 5, 2011 20:09
Show Gist options
  • Save khelll/766928 to your computer and use it in GitHub Desktop.
Save khelll/766928 to your computer and use it in GitHub Desktop.
class Spot
include Mongoid::Document
include Mongoid::Timestamps
## Fields ##
field :name_t
## Associations ##
embeds_many :items
include Sunspot::Mongoid
searchable do
text :name, :boost => 10
text :items_names do
items.map { |item| item.name }
end
end
end
s = Spot.first
s.items.build(:name=> 'Pizza')
s.save #=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment