newbie question concerning a simple thread

zack wrote:

First off, I'm a RoR beginner and am new to web dev in general, so I'm probably not going about this in the best way.

I'm trying to use to run an external application that has the potential to take a few minutes. The external app takes some info that the user has selected on the web site and creates a file from it. What I want to happen is that, when the user clicks a link, a window pops up and the external app is started, but the .rhtml file is not loaded in the popup until the external app is completed. Here's my code:

on the list page, from where they will click the link to run the external app:

<%= link_to 'External App', :action => 'extapp', :popup => ['new_window', 'height=300,width=600'] %>

in my controller:

def extapp #create file ... {system("extapp.exe")} end

in extapp.rhtml:   <%= link_to 'Download', :action => 'dl_output_file' %>

So my problem is, extapp.rhtml is loaded immediately, giving the user a link to download the file even though it hasn't been created yet. If I remove, extapp.rhtml doesn't load until the app is done, but then there is no threading and you can't do anything else.

Any help would be greatly appreciated, thanks!

You probably want to use Ajax:

Rails includes support for Ajax through the Prototype and JavaScript libraries though you can use something else or roll your own if you like.