Sha256: 5f6c2cfaebc7136ac06087e3c01219b05e8129ab3f7a03de5dda3227f86db157
Contents?: true
Size: 882 Bytes
Versions: 2
Compression:
Stored size: 882 Bytes
Contents
require 'janus/hooks/trackable' module Janus module Models # = Trackable # # Simple hook to update some columns of your model whenever a user logs in. # # == Required columns # # - +sign_in_count+ # - +current_sign_in_ip+ # - +current_sign_in_at+ # - +last_sign_in_ip+ # - +last_sign_in_at+ # module Trackable extend ActiveSupport::Concern included do attr_protected :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip end def track!(ip) self.sign_in_count += 1 self.last_sign_in_at = self.current_sign_in_at self.last_sign_in_ip = self.current_sign_in_ip self.current_sign_in_at = Time.now self.current_sign_in_ip = ip save(:validate => false) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
janus-0.6.0 | lib/janus/models/trackable.rb |
janus-0.5.0 | lib/janus/models/trackable.rb |