Paperclip gem kullanarak AngularJS/Rails ile bir dosya yüklemeyi uygulamaya çalışıyorum. Dosya giriş problemini direktifle düzelttim. Şimdi, görüntüyü gönderinin diğer verileriyle göndermek istiyorum ancak görüntü verileri gönderilmez.AngularJS/Rails Kağıt sıkışması dosya yükleme
HTML:
<form name="PostForm" ng-submit="submit()" novalidate>
<input type="text" ng-model="post.title">
<input type="file" file-upload />
<textarea ng-model="post.content"></textarea>
</form>
Benim denetleyicisi:
$scope.create = function() {
function success(response) {
console.log("Success", response)
$location.path("posts");
}
function failure(response) {
console.log("Failure", response);
}
if ($routeParams.id)
Post.update($scope.post, success, failure);
else
Post.create($scope.post, success, failure);
}
$scope.$on("fileSelected", function (event, args) {
$scope.$apply(function() {
$scope.post.image = args.file;
});
Benim modelim:
class Post < ActiveRecord::Base
attr_accessible :content, :title, :image_file_name, :image_content_type, :image_file_size, :image_updated_at
belongs_to :user
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
end
Ama sunucu tarafında göndermek zaman, istek böyledir:
{
"content":"Hey",
"created_at":"2013-08-31T17:54:32Z",
"id":17,
"image_content_type":null,
"image_file_name":null,
"image_file_size":null,
"image_updated_at":null,
"title":"Image",
"updated_at":"2013-08-31T17:54:32Z",
"user_id":4
}
Yani, görüntü ile ilgili hiçbir veri sunucuya gönderilmiyor, bunun nasıl yapılacağı ile ilgili herhangi bir ipucu var mı? Şimdi ilerleme
Hey Joe, bu kudreti yararlı https: //gist.github veri göndermek .com/vajapravin/48059fd9d64bb42f012f513cebd391ea – vajapravin