Skip to content

Instantly share code, notes, and snippets.

@chuckbergeron
Created January 19, 2012 20:58
Show Gist options
  • Save chuckbergeron/1642546 to your computer and use it in GitHub Desktop.
Save chuckbergeron/1642546 to your computer and use it in GitHub Desktop.
Append to an array, create the array first if it doesn't already exist
class AnnouncementsController < ApplicationController
# Creates an array (if needed) and stores that array in the session so we know which
# announcements the current_user has seen
#
# @todo: Add test
#
def hide
( session[:announcement_ids] ||= [] ) << params[:id]
render( :nothing => true, :status => :ok )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment