# Forcing Views

**URL:** <https://www.ruby-forum.com/t/forcing-views/147066>\
**Category:** Rails\
**Created:** [August 28, 2008, 8:03am UTC](https://www.ruby-forum.com/t/forcing-views/147066 "2008-08-28T08:03:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shomanishikawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@shomanishikawa](https://www.ruby-forum.com/u/shomanishikawa)\
**Post date:** [August 28, 2008, 8:03am UTC](https://www.ruby-forum.com/t/forcing-views/147066/1 "2008-08-28T08:03:22Z")

</div>

Hi guys,

I’m using attachment\_fu to upload large files, and when the user presses  
submit on the form action/view and calls the “create” action, it  
uploads the file, and then redirects the user to an index action/view.

However, b/c of the size of the file and the time it takes to upload, I  
would like to show the actual view for “create”, having it say something  
like “please be patient while your file uploads”.

While I have simply tried making a view for my “create” action, it does  
not work. After pressing submit on the form view, it simply stalls on  
that page while the file is being uploaded and then automatically issues  
the redirect at the end of my create action, without ever showing me the  
view for create.

How would I force the app to actually show the view that goes along w/  
create, while the file is being uploaded and before the redirect?

A very simplified version of the code:

controller:

[code=]  
def form  
@post = Post.new  
end

def create  
@post = Post.new(params[:post])  
if @post.save  
redirect\_to :action =\> ‘index’  
end  
end[/code]  
The form view:

`<% form_tag ({:action => 'create'}, :multipart => true) do %>
    <%= file_field_tag 'post', :size => 50 -%>
    <%= submit_tag 'Submit' %>
<%end%>`  
Thanks in advance for the help everyone.

-shoma

---

<div class="post-metadata">

**Author:** ![shomanishikawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@shomanishikawa](https://www.ruby-forum.com/u/shomanishikawa)\
**Post date:** [August 28, 2008, 8:08am UTC](https://www.ruby-forum.com/t/forcing-views/147066/2 "2008-08-28T08:08:17Z")

</div>

One strategy would be to use javascript to show a new div with that  
message  
just before the form is submitted, so that the user sees that div  
while waiting for the  
response.

On Aug 28, 1:03 am, Shoma N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![shomanishikawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@shomanishikawa](https://www.ruby-forum.com/u/shomanishikawa)\
**Post date:** [August 29, 2008, 1:51am UTC](https://www.ruby-forum.com/t/forcing-views/147066/3 "2008-08-29T01:51:30Z")

</div>

Thanks JDevine. I have tried your method, and have implemented the  
following lines but to no avail.

These all change the way I begin my form:

\<% form\_tag ({:action =\> ‘create’}, :multipart =\> true, :html =\>  
{:onSubmit =\> “$(hidden).show”}) do %\>

\<% form\_tag ({:action =\> ‘create’}, :multipart =\> true, :onSubmit =\>  
“$(‘hidden’).show”) do %\>

\<% form\_tag ({:action =\> ‘create’}, :multipart =\> true, :onSubmit =\>  
“$(hidden).show”) do %\>

I then have a div w/ an id of “hidden” that contains text, but hitting  
submit does not have an effect on the div.

Thanks in advance for all the help. I really appreciate it.  
-Shoma

JDevine wrote:

> One strategy would be to use javascript to show a new div with that  
> message  
> just before the form is submitted, so that the user sees that div  
> while waiting for the  
> response.
> 
> On Aug 28, 1:03ï¿½am, Shoma N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![shomanishikawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@shomanishikawa](https://www.ruby-forum.com/u/shomanishikawa)\
**Post date:** [August 29, 2008, 4:29am UTC](https://www.ruby-forum.com/t/forcing-views/147066/4 "2008-08-29T04:29:13Z")

</div>

Didn’t test it, but:

\<% form\_tag( {:action=\>‘create’}, { :multipart=\>true, :onSubmit=\>(stuff)  
} ) do %\>

?
