Skip to content

Instantly share code, notes, and snippets.

@nicolasblanco
Created May 15, 2009 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nicolasblanco/112275 to your computer and use it in GitHub Desktop.
Save nicolasblanco/112275 to your computer and use it in GitHub Desktop.
# in app/workers/testing_worker.rb
class TestingWorker < Workling::Base
def this_is_a_test(options)
File.open(options[:id], "w") { |f| 1.upto(30) { f.write "."; f.flush; sleep(1) } }
end
end
# in any controller...
def worker_test
raise ActiveRecord::RecordNotFound unless logged_in? && current_user.admin?
file_name = "/tmp/test_#{rand(1000)}"
TestingWorker.asynch_this_is_a_test(:id => file_name)
render :text => "Hello ! Time is #{Time.now}, Rails env is #{Rails.env}, rand test file file name is #{file_name}."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment