Note that there are some explanatory texts on larger screens.

plurals
  1. POUploading to Ruby on Rails from iPhone using ASIHTTPRequest
    primarykey
    data
    text
    <p>I've really hit a wall and am need of some help! Thankyou for reading this far!</p> <p>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.</p> <p>On the ASIHTTP side I'm simply writing:</p> <pre><code>[request setData:data withFileName:@"photo.jpg" andContentType:@"image/jpeg" forKey:@"asset[image]"]; </code></pre> <p>and on the ruby side I'm doing...</p> <pre><code>class Asset &lt; ActiveRecord::Base validates_attachment_presence :image has_attached_file :image end class AssetsController &lt; ApplicationController protect_from_forgery :only =&gt; [:update, :destroy] ..... </code></pre> <p>But it always fails, I'm pretty sure it's got something to do with the POST form dataset, but I am completely stuck. </p> <p>I'm getting the error:</p> <blockquote> <pre><code> Parameters: {"assets"=&gt;{"images"=&gt;#&lt;File:/var/folders/gM/gM15qjM2G3W0iVNaT1evD++++TI/-Tmp-/RackMultipart20091112-2285-2i0qq5-0&gt;}} 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 </code></pre> <p>`create'</p> </blockquote> <p>Any help would be very very gratefully received.</p> <p>Chris</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload