相关疑难解决方法(0)

POST json到rails服务器

def create
  req = ActiveSupport::JSON.decode(request.body)
  if user = User.authenticate(req["email"], req["password"])
    session[:user_id] = user.id
    render :json => "{\"r\": \"t\"}" + req
  else
    render :json => "{\"r\": \"f\"}"
  end
end
Run Code Online (Sandbox Code Playgroud)

'create'方法在控制器中并映射到"/ login",我正在设置正确的内容类型并从我的curl客户端接受标题.我一直收到422 http状态响应.

有什么建议?

ruby post json ruby-on-rails http

25
推荐指数
1
解决办法
3万
查看次数

标签 统计

http ×1

json ×1

post ×1

ruby ×1

ruby-on-rails ×1