Created
March 18, 2009 19:41
-
-
Save heycarsten/81343 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## application_controller.rb | |
def refresh_to(url, timeout = 10) | |
headers['Refresh'] = "#{timeout}; URL=#{url}" | |
end | |
## photo_albums_controller.rb | |
def create | |
@photo_album = @school.photo_albums.create(params[:photo_album]) | |
if @photo_album.valid? | |
PhotoAlbum.async_create_photos(@photo_album, params[:photo_uploads].values) | |
refresh_to edit_photo_album_path(@photo_album), 60 | |
render :action => 'processing', :status => 202 | |
else | |
render :action => 'form' | |
end | |
end | |
# Or, perhaps this... | |
def create | |
@photo_album = @school.photo_albums.create(params[:photo_album]) | |
if @photo_album.valid? | |
PhotoAlbum.async_create_photos(@photo_album, params[:photo_uploads].values) | |
render :action => 'processing', :refresh => [60, edit_photo_album_path(@photo_album)] | |
else | |
render :action => 'form' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment