Sha256: 360573f11dc9bdff7b28f436b0af060063200e47e2a2906848f4a7da89e92802
Contents?: true
Size: 879 Bytes
Versions: 6
Compression:
Stored size: 879 Bytes
Contents
#--- # Excerpted from "Scripted GUI Testing With Ruby", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information. #--- require 'digest/sha1' class Party < ActiveRecord::Base has_many :guests after_create :assign_permalink def to_param permalink end def after_initialize if new_record? self.begins_at ||= Time.now.monday + 5.days + 22.hours self.ends_at ||= begins_at + 4.hours end end private def assign_permalink plaintext = "#{id}-#{Time.now.to_f}-{rand}" update_attribute :permalink, Digest::SHA1.hexdigest(plaintext) end end
Version data entries
6 entries across 6 versions & 1 rubygems