Ruby on rails Rails请求返回状态200,但没有响应数据
我有一个rails操作,如下所示:Ruby on rails Rails请求返回状态200,但没有响应数据,ruby-on-rails,ruby,http,nginx,Ruby On Rails,Ruby,Http,Nginx,我有一个rails操作,如下所示: def create ...... if @course.save render json: { success: true, course: @course.info} else render json: { success: false, error_msg: @course.errors.full_messages } end 请求返回状态200,但没有响应数据 nginx日志和rails日志看起来正常: # ngi
def create
......
if @course.save
render json: { success: true, course: @course.info}
else
render json: { success: false, error_msg: @course.errors.full_messages }
end
请求返回状态200,但没有响应数据
nginx日志和rails日志看起来正常:
# nginx log
100.116.224.40 [14/Aug/2018:18:59:12 +0800] POST "xxxxx" 200 200 27
"47.88.138.112" xxx
# rails log
method=POST path=xxxxformat=*/* controller=xxxx action=create
status=200 duration=45.94 view=0.23 params=
由于课程可能是散列,请尝试
course[“info”]
如果仍然不起作用,您可能需要使用
JSON.parse(当然是[“info”])将信息哈希转换为JSON
@Gabbar感谢您的回复!,我试过了,但还是不起作用!你有没有试过就在你的if声明下面的byebug?@course.info的值是多少?@course.info是一个散列,如果我删除它,仍然不起作用。