Skip to content

Instantly share code, notes, and snippets.

@bleonard
Created April 14, 2017 22:02
Show Gist options
  • Save bleonard/98ebea144768d7e670bf01b152669be1 to your computer and use it in GitHub Desktop.
Save bleonard/98ebea144768d7e670bf01b152669be1 to your computer and use it in GitHub Desktop.
class UserIndexWorker
include TResque::Worker
inputs :id, :first_name, :last_name, :etc
def work
Elasticsearch.index('users').write(id, id: id, first_name: first_name, last_name: last_name, etc: etc)
end
end
# When user changes
UserIndexWorker.enqueue(user.attributes.slice(:id, :first_name, :last_name, :etc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment