Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have not done it, but I think you'll have to use the <a href="https://github.com/thoughtbot/paperclip" rel="nofollow">paperclip</a>.</p> <p>Add this line to your gemfile</p> <pre><code>gem "paperclip", "~&gt; 2.4" </code></pre> <p>Then in your Picture model</p> <pre><code>has_attached_file :image, :styles =&gt; { :medium =&gt; "150x150&gt;", :thumb =&gt; "50x50#" } # you don't need the styles, I just put them there so you know you can. </code></pre> <p>make a migration</p> <pre><code>class AddImageToPicture &lt; ActiveRecord::Migration def self.up add_column :picture, :image_file_name, :string add_column :picture, :image_content_type, :string add_column :picture, :image_file_size, :integer end </code></pre> <p>end run the migration.</p> <p>in you phonegap app you could do. </p> <pre><code>&lt;form accept-charset="UTF-8" action="/pictures" class="picture_user" enctype="multipart/form-data" id="new_user" method="post"&gt; &lt;input id="user_image" name="user[image]" type="file"&gt; &lt;/form&gt; </code></pre> <p>But there might be a better way to to the form. Not Tested</p> <p><strong>update</strong> you can try this as it is. The key is to send in the right options for paperclip. Make a rails app with paperclip and find the options paperclip sends to the sever from the form. Then add the options to the FileUploadOptions();</p> <pre><code>var options = new FileUploadOptions(); options.fileKey="file"; options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); options.mimeType="image/jpeg"; options.params = params; var ft = new FileTransfer(); ft.upload(imageURI, "http://some.server.com/upload.php", win, fail, options); </code></pre>
 

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