Skip to content

Instantly share code, notes, and snippets.

@npj
Created June 3, 2012 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npj/2863154 to your computer and use it in GitHub Desktop.
Save npj/2863154 to your computer and use it in GitHub Desktop.
# app/models/my_model.rb
class MyModel < ActiveRecord::Base
def async_background_method(arg1, arg2)
Queue::Normal.enqueue(self, :background_method, arg1, arg2)
end
# this happens in the background,
def background_method(arg1, arg2)
# do something that takes a long time...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment