I am a kind of new on ROR, I want to upload an image using simple input tag and don't want to use form for that. The basic functionality of Paperclip is known to me. If I am not wrong then the format of object that is being passed to save image is :
"image_object"=>
[#< ActionDispatch::Http::UploadedFile:0xb5ad25f4
@content_type="image/gif",
@headers=
"Content-Disposition: form-data; name=\"pic[]\"; filename=\"test.gif\"\r\nContent-Type: image/gif\r\n",
@original_filename="test.gif",
@tempfile=#<File:/tmp/RackMultipart20131112-17750-1lprijc>>]
I want to upload image using the following steps: 1. Using Jquery, I want to fetch the appropriate details(file parameter) of selected image in input tag and send those using Jquery/ajax. 2. By passing that parameters to rails controller I want to use those details to generate an object(as sample shown above) that can be used to save Image in my application.
My questions are: 1. which Jquery method should I use and what are the parameters that are necessary to generate the image object? 2. On controller side, how to generate Image Object using those details?
Thanks in advance.