The tutorials I have been reading about using paperclip all include something like this
<% form_for @product, :html => { :multipart => true } do |form| %>
<ol class="formList">
<!-- Other fields go here... -->
<li>
<%= form.label :photo, "Photo" %>
<%= form.file_field :photo %>
<li>
<%= form.submit "Submit" %>
</li>
</ol>
<% end %>
This seems to me like you need to upload a photo before you click submit. On my site, I want users to be able to create a product, then afterwards if they want to add a photo, click on an upload photo button in the product view. Then the uploaded photo would be added to the product. Is this possible using paperclip or anything else? or do I need to have a separate photo/image model and submit it through that?
Well even if it’s only about adding a photo to a product, you still are performing an update of the product model. So it should be a normal form for the product model like the one you posted, but without the other fields. Just make a different form view for just that add-photo process.
You can pass a parameter like ?photo=1 to the edit action of the products resource in order to render the correct view and perhaps make that edit-action ajax-like, so it appears a bit more on-the-fly. However, the update-action of the model will not be possible to do via ajax, since your uploading an image.