Created
April 14, 2017 22:03
-
-
Save bleonard/bc04bffc3a1d8d0c91da205fa813d26b to your computer and use it in GitHub Desktop.
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 UserIndexWorker | |
include TResque::Worker | |
inputs :user_id | |
def work | |
Elasticsearch.index('users').write(user.attributes.slice(:id, :first_name, :last_name, :etc)) | |
end | |
def user | |
@user ||= User.find(user_id) | |
end | |
end | |
# When user changes | |
UserIndexWorker.enqueue(user_id: user.id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment