Skip to content

Instantly share code, notes, and snippets.

Created August 25, 2010 21:28
Show Gist options
  • Save anonymous/550339 to your computer and use it in GitHub Desktop.
Save anonymous/550339 to your computer and use it in GitHub Desktop.
def card_assign card, employee
active_card = card.card_assignments.all(:conditions=>["active_since < #{DateTime.now} and #{DateTime.now} < active_until"]).first
if not current_card.nil? then
active_card.active_until = DateTime.now
end
active_card = CardAssignment.new
active_card.active_since = DateTime.now
active_card.active_until = DateTime.now + 1 year
active_card.first_time = true
employee.card_assignments.add active_card
card.card_assignments.add active_card
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment