add post request error checking and resend one more time

This commit is contained in:
thomaschen 2013-09-23 12:46:59 +08:00
parent b57b899dba
commit 0d1426cab8
2 changed files with 15 additions and 15 deletions

View File

@ -58,20 +58,20 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
'tax' => current_question.tax, 'tax' => current_question.tax,
'content' => current_question.content, 'content' => current_question.content,
} }
#binding.pry
for i in 0..1
request.set_form_data(body) request.set_form_data(body)
request.add_field 'X-Auth-Token', '3kjlfksjDFJ' request.add_field 'X-Auth-Token', '3kjlfksjDFJ'
response = http.request(request) response = http.request(request)
# binding.pry
if response.code != "200" if response.code != "200"
# Think about another rescue method. new_status = "部份傳送失敗"
new_status = "轉介其他單位" current_reply.update_attributes(status: new_status)
current_reply.update_attributes(status: new_status) elsif response.code == "200" && (current_reply.status != "部份傳送失敗")
else
new_status = "轉介其他單位" new_status = "轉介其他單位"
current_reply.update_attributes(status: new_status) current_reply.update_attributes(status: new_status)
break
end
end end
puts "Response #{response.code} #{response.message}: #{response.body}" puts "Response #{response.code} #{response.message}: #{response.body}"
# flash[:notice] = response.body # flash[:notice] = response.body
# flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}" # flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}"

View File

@ -2,7 +2,7 @@
class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController
include AdminHelper include AdminHelper
include OrbitControllerLib::DivisionForDisable include OrbitControllerLib::DivisionForDisable
# skip_before_filter :verify_authenticity_token skip_before_filter :verify_authenticity_token
def transfer_request def transfer_request