我发送了这个帖子底部的参数,但是它们被发布到Load而不是Hotload
你能看到我在这里做错了吗?
我发送了一个hotload参数,所以它应该将post_type更改为Hotload
class MajorPoster
@queue = :major_posters_posting
def self.perform(_post)
post_clone = _post.clone
post_type = Load
post_type = Hotload if (_post[:hotload])
post_type = Truck if (_post[:available])
begin
result = post_type.send("post",_post)
rescue => detail
Resque.enqueue(SecondChance, { :queue => "major_posters_posting", :post => post_clone, :exception_class => detail.class.to_s, :exception_str => detail.to_s })
else
Notification.check(result.id, post_type)
#TODO
end
end
end
在...中发送params的日志文件。
{:equipment_id=>34, :comments=>"9145662 ~Load Max~", :user_id=>"10181", :origin=>"Cy Of Industry, CA", :dest=>"Loveland, CO", :pickup=>2014-07-08 12:00:00 -0500, :delivery=>2014-07-10 12:00:00 -0500, :rate=>"CALL", :length=>"53", :hotload=>"True"}
{:equipment_id=>34, :comments=>"9163608 ~Load Max~", :user_id=>"10181", :origin=>"Auburndale, FL", :dest=>"Paw Paw, MI", :pickup=>2014-07-06 12:00:00 -0500, :delivery=>2014-07-09 12:00:00 -0500, :rate=>"CALL", :length=>"53", :hotload=>"True"}
{:equipment_id=>34, :comments=>"9158096 ~Load Max~", :user_id=>"10181", :origin=>"Auburndale, FL", :dest=>"Paw Paw, MI", :pickup=>2014-07-03 12:00:00 -0500, :delivery=>2014-07-06 12:00:00 -0500, :rate=>"CALL", :length=>"53", :hotload=>"True"}
{:equipment_id=>34, :comments=>"9163315 ~Load Max~", :user_id=>"10181", :origin=>"Auburndale, FL", :dest=>"Paw Paw, MI", :pickup=>2014-07-03 12:00:00 -0500, :delivery=>2014-07-06 12:00:00 -0500, :rate=>"CALL", :length=>"53", :hotload=>"True"}
答案 0 :(得分:1)
您发送的参数的键是符号,而不是字符串 - 您应该相应地更改代码:
def self.perform(_post)
post_clone = _post.clone
post_type = Load
post_type = Hotload if (_post[:hotload])
post_type = Truck if (_post[:available])
# ...