module JamRuby # some times someone comes to signup as a new user, but there is context to preserve. # the AnyUser cookie is one way that we can track the user from pre-signup to post-signup # anyway, once the signup is done, we check to see if there is a SignupHint, and if so, # we use it to figure out what to do with the user after they signup class SignupHint < ActiveRecord::Base belongs_to :user, class_name: 'JamRuby::User' validates :redirect_location, length: {maximum: 1000} validates :want_jamblaster, inclusion: {in: [nil, true, false]} def self.refresh_by_anoymous_user(anonymous_user, options = {}) hint = SignupHint.find_by_anonymous_user_id(anonymous_user.id) unless hint hint = SignupHint.new end hint.anonymous_user_id = anonymous_user.id hint.redirect_location = options[:redirect_location] if options.has_key?(:redirect_location) hint.want_jamblaster = options[:want_jamblaster] if options.has_key?(:want_jamblaster) hint.expires_at = 15.minutes.from_now hint.save hint end def self.delete_old SignupHint.where("created_at < :week", {:week => 1.week.ago}).delete_all end end end