我有一个奇怪的问题。
我尝试了很多不同的东西来重现这个问题,但这是不可能的。由于exception_notification,错误显示出来。
我正在向后端发送一个NSDictionary,而不是被解析为字典,这是我得到的(在轨道方面):
* Parameters : {"{\"facebook_id\":\"\",\"city\":\"\",\"account_type\":\"email\",\"poll_reminder\":\"0\",\"last_name\":\"\",\"picture_url\":\"\",\"email\":\"\",
\"birthday\":\"\",\"users_value_categories_attributes\":"=>{"{\"value_category_id\":25},{\"value_category_id\":24},
{\"value_category_id\":21},{\"value_id\":24,\"priority\":14},{\"value_id\":21,\"priority\":15},
{\"value_id\":58,\"priority\":16},
{\"value_id\":8,\"priority\":17},{\"value_id\":9,\"priority\":18},{\"value_id\":41,\"priority\":19},
{\"value_id\":27,\"priority\":20}"=>{",\"first_name\":\"\"}"
=>nil}}}}}
字典中唯一的键是我的序列化字典!
这是铁路方面的错误:
An ActiveRecord::UnknownAttributeError occurred in #:
unknown attribute: {"facebook_id":"","city":"","account_type":"email","poll_reminder":"0","last_name":"","picture_url":"","email":"","birthday":"",":...........
app/api/v2/resources/example_business_api.rb:6:in `block in <class:ExampleBusinessApi>'
params hash就像:
{"<MY SERIALIZED DICTIONARY" => nil }
而不是字典本身。
iOS中的相关代码是:
request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[self getHTTPBodyForUser:theUser]];
getHTTPBodyForUser如下:
+ (NSData *)getHTTPBodyForUser:(User *)user {
// Load a tmp dictionary using user variable
....
// The tmp dictionary is totally fine
NSError *error;
NSData *postdata = [NSJSONSerialization dataWithJSONObject:tmp options:0 error:&error];
return postdata;
}
奇怪的是,只有一些用户有错误.....
任何帮助?