Created
January 19, 2013 21:06
-
-
Save lgs/4575131 to your computer and use it in GitHub Desktop.
RAILS_ENV=production rake environment tire:import CLASS=User FORCE=true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
include Mongoid::Document | |
include Tire::Model::Search | |
include Tire::Model::Callbacks | |
tire do | |
mapping do | |
indexes :nickname | |
indexes :watchlists do | |
indexes :description | |
indexes :html_url | |
indexes :tags | |
end | |
end | |
end | |
def to_indexed_json | |
{ | |
:nickname => nickname, | |
:watchlists => watchlists.map { |c| { :_type => 'mongoid_watchlist', | |
:_id => c.id, | |
:description => c.description, | |
:html_url => c.html_url, | |
:tags => c.tags } } | |
}.to_json | |
end | |
field :nickname | |
embeds_many :watchlists | |
end | |
class Watchlist | |
include Mongoid::Document | |
field :description | |
field :html_url | |
field :tags | |
embedded_in :user | |
end | |
RAILS_ENV=production rake environment tire:import CLASS=User FORCE=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment