I am getting back to an earlier post:
"Understanding the Hobo <form>
In that I mentioned being unable to get a form to post to the database
when update is used with a Paperclip attachment. I am using the
paperclip
plugin and the paperclip_with_hobo plugin.
When I use this form:
<form with="&@project.photo" >
<field-list: fields="mainimg" />
<actions: />
</form>
The image is saved to the database, and I stay on the current page,
because I have <after-submit stay-here /> in my form:
<def tag="form" for="Photo">
<form merge multipart param="default">
param="photo-object"/> -->
<error-messages param/>
<field-list fields="mainimg,lwrimg,uprimg" param/>
<div param="actions">
<submit label="Save" param/> <!--<or-cancel param="cancel"/> --
>
</div>
<after-submit stay-here />
</form>
</def>
I am trying to upload an image file and save it to d.b., and then load
that image into a <div>
on the page:
<div id="imgmain" part="photomain">
<%= render :partial => 'photos/mainphoto'%>
</div>
This is the partial:
<%= (@photo == nil) ? '<img src="/images/main_tmp_display.jpg" />' :
image_tag @photo.mainimg.url %>
The syntax must be wrong for
image_tag @photo.mainimg.url
because it generates an error. I could use help on that.
But back to the form issue, if I change the form to:
<form with="&@project.photo" update="imgmain" >
<field-list: fields="mainimg" />
<actions: />
</form>
The image file does not get saved to the database.
I appreciate the suggestions from Kevin and Bryan,
but the examples you mentioned were not photos.
Text updating does work. It appears that images do not.
I believe that something is broken in regard to saving images,
or there is some information I have missed. However, in the
Notice that I am passing an instance of @project.photo to the form.
I am creating that in the project controller. The form without the
'update' correctly saves the photo, but the form with update does not.
Do I need to pass the @project.photo instance in the params hash?
I am now using a dynamic <div> with a partial, so that would satisfy
the
condition Kevin mentioned about the content being static.
What I am really looking for is a solution. If update is broken with
images,
what are some suggestions for an alternative? I have tried an rjs
approach,
but get directed to a 'photo' page instead of reloading the 'projects/
new' page.
If anyone has example or has been successful in uploading an image,
then
updating a partial with that image using Paperclip, I really would
like to
hear about it.
Cheers,
Jet
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---