0

am sending in the parameters that are at the bottom of this posting but they are getting posted to Load instead of Hotload

Can you see what i am doing wrong here...

i am sending in a parameter of hotload so it should change the post_type to 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

log file of params being sent in...

{: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"}

1 Answer 1

1

The keys of the params you are sending are symbols, not strings - you should change the code accordingly:

def self.perform(_post)
  post_clone = _post.clone
  post_type  = Load
  post_type  = Hotload if (_post[:hotload])
  post_type  = Truck if (_post[:available])
  # ...
Sign up to request clarification or add additional context in comments.

1 Comment

try printing puts _post[:hotload] inside the method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.