在我的控制器中,我在第20行有以下内容:
data = JSON.parse(params[:error])
我正在尝试发布帖子并将结果格式化为JSON,以便我可以执行以下操作:
title = data['title']
但是这个500以下有以下
Started POST "/api/services/"
Processing by Api::ServicesController#create as XML
Parameters: {"{\"error\":{\"id\":313131313,\"title\":\"# (Test-20) \\\"Test message-20\\\"\",\"sub_title\":null,\"app\":{\"id\":313131,\"name\":\"site.com\"},\"last_occurrence\":{\"id\":3131313133,\"request_method\":null,\"url\":null,\"occurred_at\":\"2012-11-30T04:27:01 00:00\",\"backtrace\":null},\"environment\":null,\"first_occurred_at\":\"2012-11-30T04:27:01 00:00\",\"last_occurred_at\":\"2012-11-30T04:27:01 00:00\",\"url\":\"http://getexl.com/123\"}}"=>nil, "token"=>"xxxxxx"}
Completed 500 Internal Server Error in 12ms
TypeError (can't convert Array into String):
app/controllers/api/services_controller.rb:20:in `create'
lib/rack/ie_redirect.rb:19:in `call'
关于如何将此帖子格式化为JSON的任何想法?感谢