Class: QueuesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/queues_controller.rb

Instance Method Summary collapse

Instance Method Details

#receiveObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/queues_controller.rb', line 5

def receive
  p params
  body = request.body.read
  p body
  json = JSON.parse(body)
  begin
    job = json["class"].constantize.new
    # the following is for Resque 2.X
    #json["vars"].each {|k, v| job.instance_variable_set("@#{k}", v) }
    #job.work
    args = json["args"]
    job.perform(*args)
    render :json => {"got" => "it"}
  rescue Exception => ex
    render :status => 500, :json => {"error"=>"#{ex.message}"}
  end
end