Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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
Objective c 渲染时缺少模板_Objective C_Ruby On Rails_Afnetworking - Fatal编程技术网

Objective c 渲染时缺少模板

Objective c 渲染时缺少模板,objective-c,ruby-on-rails,afnetworking,Objective C,Ruby On Rails,Afnetworking,我的错误: ActionView::MissingTemplate (Missing template api/magic_photos/create, api/base/create, application/create with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :y

我的错误:

 ActionView::MissingTemplate (Missing template api/magic_photos/create, api/base/create, application/create with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :coffee, :rabl]}. Searched in:
2014-08-15T16:15:45.610918+00:00 app[web.1]:
2014-08-15T16:15:45.610928+00:00 app[web.1]:   * "/app/app/views"
2014-08-15T16:15:45.610929+00:00 app[web.1]:   * "/app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.2/app/views"
控制器代码:

  if photo.save
    magic_photo = photo.magic_photos.build( magic: magic )
    magic_photo.save
    render json: photo.json_hash(magic, current_user)
  else
    render status: 500
  end
一卷

curl-X POST-F“photo=@/path/path.jpg;type=image/jpg”“”

工作并返回JSON

当我提出这个请求时,我得到一个500和缺少的模板错误

description = [description stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSString *path = [NSString stringWithFormat:@"api/magics/%@/photos?description=%@&auth_token=%@", magic.identifier, description, [NSUserDefaults authToken]];

NSString *fullPath = [NSString stringWithFormat:@"%@%@", [CURequestHelpers baseURL], path];

NSData *imageData = UIImageJPEGRepresentation(image, 0.25f);
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[CURequestHelpers baseURL]];

NSURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:path parameters:@{} constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    NSString *fileName = @"image.jpg";
    [formData appendPartWithFileData:imageData name:@"image" fileName:fileName mimeType:@"image/jpg"];
}];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];


[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    [self.delegate pictureUploadProxyUploadDidSucceed:self];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"UPLOAD ERROR RESPONSE: %@", operation.responseString);
    NSLog(@"UPLOAD ERROR: %@", error);
    [self.delegate pictureUploadProxyUploadDidFail:self];
}];

NSOperationQueue *q = [[NSOperationQueue alloc] init]; [q addOperation:operation];
编辑:

显示的实际错误是“图像不能为空”


Doh。我把参数搞错了。只需要请某人检查一下。

检查您的验证,有什么东西阻止保存您的模型,并将其放入您的
其他
语句中

错误消息应该会告诉您问题所在

您可能还存在以下问题:

render status: 500
这是导致混淆和
丢失模板
错误的原因,您缺少模板参数

render :template => "public/500.html", :status => 500
编辑quantumpotato


问题是,从Obj-C代码发送的图像是使用
image
查询参数发送的,而不是
photo

curl中有API,抱歉,我忘了。他在打字!那你的MagicPhoto模型呢,有没有验证呢?我上传的是“image”,因为那是模型的名字,但是使用的参数是“photo”。如果你想改变你的答案,我会接受并奖励赏金。自从您提出验证:)完成。还添加了一些关于丢失模板问题的备注。
render :template => "public/500.html", :status => 500