Rails 用 scaffold 生成一行了代码看不懂

shangrenzhidao · October 17, 2014 · Last by shangrenzhidao replied at October 17, 2014 · 1427 hits
format.json { render action: 'show', status: :created, location: @line_item }

这行代码返回给浏览器,浏览器发生了什么行为?

发送 POST 请求,请求格式是 json 才会运行这个,会返回新创建 model 的 json,HEAD 中 status 是 201 created,Location 是新创建 model 的 URL

哈哈,想起来了!谢谢

You need to Sign in before reply, if you don't have an account, please Sign up first.