public
Last active

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.