Problem
You need to display a splash screen when uploading files to a Ruby on Rails application.
Solution
My model:
class Number < ActiveRecord::Base file_column :intro file_column :vmail end
The steps I have followed.
- Install redbox plugin from project path run:
./script/plugin install svn://rubyforge.org/var/svn/ambroseplugins/redbox
- If files redbox.js, redbox.css and redbox_spinner.gif haven’t been copied over to the public folders copy them over manually or go to vendor/plugins/redbox and run:
rake update_scripts
- Find an animated gif for the progress indicator to be used (ie pleasewait.gif) and copy it over to public/images.
- In order to be able to use the progress indicator in different parts of the application, add the following to the app/views/layouts/ :
application.rhtml <%= stylesheet_link_tag 'redbox' %> <%= javascript_include_tag 'redbox' %>
near the place where <= javascript_include_tag :default > is located.
Also at the bottom of the page create the content of the redbox:<p id="redbox" style="display: none"> </p> <p style="color: blue"> Please wait .... Uploading files <img src="/images/pleasewait.gif" width="200" />
- Copy _update_form.rhtml, update_form.rhtml and update.rjs from vendor/plugins/active_scaffold_upload/frontends/default/views/ to the app/views/numbers (model you want to use).
- To display the redbox in the numbers/_update_form.rhtml add the following in the submit_tag:
, :onClick => "return RedBox.showInline('redbox') " %>
- To close the redbox after the uploading was successful, add the following in numbers/update.rjs as the first line inside controller.send :successful? clause:
page.RedBox.close()