Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails请求返回状态200,但没有响应数据_Ruby On Rails_Ruby_Http_Nginx - Fatal编程技术网

Ruby on rails Rails请求返回状态200,但没有响应数据

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

我有一个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日志看起来正常:

# 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是一个散列,如果我删除它,仍然不起作用。