Hi,
I've really hit a wall and am need of some help! Thankyou for reading this far!
I'm in the middle of writing an app that talks to my ROR web-server for database requests and works great thanks to ActiveResource. But I now need to also upload files to the server, and I plan to use ASIHTTPRequest which looks great, my problem though is I'm just not sure how to hand the POST request on the ROR side... I'm using paperclip but have really hit a brick wall.
On the ASIHTTP side I'm simply writing:
[request setData:data withFileName:@"photo.jpg" andContentType:@"image/jpeg" forKey:@"asset[image]"];
and on the ruby side I'm doing...
class Asset < ActiveRecord::Base
validates_attachment_presence :image
has_attached_file :image
end
class AssetsController < ApplicationController
protect_from_forgery :only => [:update, :destroy]
.....
But it always fails, I'm pretty sure it's got something to do with the POST form dataset, but I am completely stuck.
I'm getting the error:
Parameters: {"assets"=>{"images"=>#<File:/var/folders/gM/gM15qjM2G3W0iVNaT1evD++++TI/-Tmp-/RackMultipart20091112-2285-2i0qq5-0>}} NoMethodError (You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[]): app/models/asset.rb:2 app/controllers/assets_controller.rb:46:in
`create'
Any help would be very very gratefully received.
Chris
Thanks!