Skip to content

Instantly share code, notes, and snippets.

@heycarsten
Created March 18, 2009 19:41
Show Gist options
  • Save heycarsten/81343 to your computer and use it in GitHub Desktop.
Save heycarsten/81343 to your computer and use it in GitHub Desktop.
## 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