我正在制作一个内部http请求,从一个方法转发另一个方法转发信息,但是当我发布第二个方法时,第二个方法在第二个方法的查询中完全冻结,我已经尝试使用另一个另一个数据库了,新项目,有关正在发生的事情的任何想法?
路线
post 'rest/login'
post 'rest/verify_user/:email', to: 'auth#verify_user', as: 'verify', constraints: { email: /.*/ }
resources :users
方法1
class RestController < ApplicationController
protect_from_forgery with: :null_session, only: Proc.new { |c| c.request.format.json? }
def login
response = RestClient.post(verify_url(params[:email]),
{'image' => params[:image]}.to_json,
{content_type: :json, accept: :json})
end
end
方法2
class AuthController < ApplicationController
protect_from_forgery with: :null_session, only: Proc.new { |c| c.request.format.json? }
def verify_user
email = params[:email]
user = User.find_by(email: email)
if user
image = JSON.parse(request.raw_post)
diff = distance_percent(user.image,image["image"])
if diff <= 10
render status: 200
else
render status: 40
end
else
render status: 404
end
end
end