Forum: Ruby on Rails file_column preview in multistage forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 Adam Denenberg (Guest)
on 2006-01-12 14:45
(Received via mailing list)
i have a 2 step form which contains 1 file_column field.

The second form is just "This is how your post will look" kind of form
and the user can click Edit (to take them back to form1) or Submit.
If the user clicks edit it takes them back to the first form with
fields populated.  I have it working with all text fields, I just dont
know how to do this with file_column field (showing the image and file
selected).  Storing the @params[:post]["image"] field in a session
crashes rails.  So what i cant figure out is

1) how do i reference the temporary image in my second form to show
how the post will look
2) how do i re-populate the user's choice in the first form if there
is an error, or the user wants to go back and edit from form2?

thanks
adam
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 Adam Denenberg (Guest)
on 2006-01-12 16:48
(Received via mailing list)
shameless bump since i am sure there is a helper to help do this !
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-01-12 20:57
(Received via mailing list)
On 1/12/06, Adam Denenberg <straightflush@gmail.com> wrote:
> > selected).  Storing the @params[:post]["image"] field in a session
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

That behavior should work with the default find_column_field helper.

--
Kyle Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 Adam Denenberg (Guest)
on 2006-01-12 23:50
(Received via mailing list)
i am not sure how.  if i have a file_column_field in step1, and i only
want to display the image without putting another "Browse" button on
the second step (which i now figured out how to do as a sort of
preview step), the params[:post]["image"] attribute is now gone, as is
the image when the controller gets it on submission

.  How do you drop this in the second step form, so that when the user
clicks submit on step2, @params[:post]["image"] goes with it (using
the image chosed in step1) ?

Maybe i am missing something here, but i dont see how this is possible.

thanks
adam
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-01-13 00:45
(Received via mailing list)
On 1/12/06, Adam Denenberg <straightflush@gmail.com> wrote:
> Maybe i am missing something here, but i dont see how this is possible.
> > > >
> > > > 2) how do i re-populate the user's choice in the first form if there
> >
> > Rails mailing list
> > Rails@lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> >
> >
> >
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

The absolute easiest way would be to <div
style="visibility:hidden"><%=file_column_field ... %></div>.  I'll let
you figure out equivalent methods.

--
Kyle Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
7cc2183535871f7c5c22b7e957a224b0?d=identicon&s=25 Joseph Chan (Guest)
on 2006-01-13 00:57
(Received via mailing list)
Adam,

How about this: first action creates the object containing the image and
populates it from 'params'.    Keep it in a instance variable like
@my_image
and also put it into the session, @session['partial_image'] = @my_image.
Render your preview page using:

<%= image_tag url_for_file_column("@my_image", "image_column")

In your second action, retrieve the partial image object and perform a
save.

I'm doing this in my current app.

Joe
This topic is locked and can not be replied to.