【发布时间】:2015-07-20 07:30:28
【问题描述】:
我收到来自第三方 URL 的 POST 请求并将数据更新到我的数据库。
在config/environments/production.rb,我有:
config.force_ssl = true
现在,当我收到请求时,我的控制台中出现以下错误。
Started POST "/delivery_details" for 35.355.466.466 at 2015-07-20 17:11:51 +1000
Processing by DeliveryDetailsController#create as HTML
Parameters: {"data"=>"{\"numbers\":{\"911234567890\":{\"desc\":\"MESSAGE\",\"status\":1,\"userId\":\"35534\",\"senderId\":\"qwerty\",\"date\":\"2015-07-20 12:41:59.0\"}},\"requestId\":\"12345566778\"}"}
Completed 401 Unauthorized in 1ms
Started GET "/users/sign_in" for 35.355.466.466 at 2015-07-20 17:11:51 +1000
Cannot render console from 35.355.466.466! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Devise::SessionsController#new as HTML
Rendered devise/sessions/new.html.erb within layouts/application (55.3ms)
Rendered layouts/_header.html.erb (3.9ms)
Rendered layouts/_menu.html.erb (0.1ms)
Rendered layouts/_footer.html.erb (7.5ms)
Completed 200 OK in 82ms (Views: 78.6ms | ActiveRecord: 0.0ms)
我的控制器:
class DeliveryDetailsController < ApplicationController
skip_before_action :verify_authenticity_token
def index
updateSmsDeliveryStatus
end
def updateSmsDeliveryStatus
destinationType = "SMS"
json = JSON.parse(params["data"])
requestId = json["requestId"]
numbers = json['numbers']
numbers.each do |num|
@delivery_detail = DeliveryDetail.where(sms_request_id: requestId, destination_value: num[0].to_s,
destination_type: destinationType)
.update_all(:is_success => num[1]["status"], :sent_date => num[1]["date"])
end
end
end
【问题讨论】:
标签: ruby-on-rails json ruby-on-rails-4 post devise