Rails冻结内部http请求

时间:2017-10-27 22:46:29

标签: ruby-on-rails ruby-on-rails-4

我正在制作一个内部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

0 个答案:

没有答案