Created
August 10, 2014 01:50
-
-
Save aledalgrande/e958581338e1e44be46c to your computer and use it in GitHub Desktop.
Sidekiq Elasticsearch
This file contains 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
# app/models/article.rb | |
class Article < ActiveRecord::Base | |
include Elasticsearch::Model | |
# include Elasticsearch::Model::Callbacks | |
after_update :update_elasticsearch_index | |
def update_elasticsearch_index | |
ElasticSearchWorker.perform_async(Article, id) | |
end | |
end |
This file contains 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
# workers/elasticsearch_worker.rb | |
class ElasticsearchWorker | |
include Sidekiq::Worker | |
def perform(klass, id) | |
object = klass.find(id) | |
object.update_document | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment