nictrix nictrix - 11 months ago 58
Ruby Question

ruby httparty get response url or id after post

How can I get the response url or id from a rails project with httparty in a separate script after doing a post?

ruby script:'http://localhost:3000/change_logs', parameters)

response.body and all the others ones do not show the url and the response id

Answer Source

This works for me, there's probably a better way to do this though..

get_change_log_id ='http://localhost:3000/change_logs.xml', parameters).to_a

get_change_log_id.each do |r|
  r.each do |sub|
    sub2 = sub.to_a
      sub2.each do |s|
        if s.index "id"
          @change_log_id = s.to_s.sub(/[i]/, '').sub(/[d]/, '')