Sha256: 4fd2c865f76b014d2a7e0389e02d34ef6479400e5d1195f0cc364c4fe4a54b6b

Contents?: true

Size: 713 Bytes

Versions: 48

Compression:

Stored size: 713 Bytes

Contents

module Incline
  class UserLoginHistory < ActiveRecord::Base

    belongs_to :user
    after_save :update_user_comments

    validates :user, presence: true
    validates :ip_address, presence: true, length: { maximum: 64 }, 'incline/ip_address' => { no_mask: true }
    validates :message, length: { maximum: 200 }

    def time_and_ip
      "#{created_at.in_time_zone.strftime('%m/%d/%Y %H:%M')} from #{ip_address}"
    end

    def date_and_ip
      "#{created_at.in_time_zone.strftime('%m/%d/%Y')} from #{ip_address}"
    end

    def to_s
      "Login #{successful ? 'succeeded' : 'failed'} on #{time_and_ip}"
    end

    private

    def update_user_comments
      user.refresh_comments
    end

  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 app/models/incline/user_login_history.rb
incline-0.3.13 app/models/incline/user_login_history.rb
incline-0.3.12 app/models/incline/user_login_history.rb
incline-0.3.11 app/models/incline/user_login_history.rb
incline-0.3.10 app/models/incline/user_login_history.rb
incline-0.3.9 app/models/incline/user_login_history.rb
incline-0.3.8 app/models/incline/user_login_history.rb
incline-0.3.7 app/models/incline/user_login_history.rb
incline-0.3.6 app/models/incline/user_login_history.rb
incline-0.3.5 app/models/incline/user_login_history.rb
incline-0.3.4 app/models/incline/user_login_history.rb
incline-0.3.3 app/models/incline/user_login_history.rb
incline-0.3.2 app/models/incline/user_login_history.rb
incline-0.3.1 app/models/incline/user_login_history.rb
incline-0.3.0 app/models/incline/user_login_history.rb
incline-0.2.36 app/models/incline/user_login_history.rb
incline-0.2.35 app/models/incline/user_login_history.rb
incline-0.2.34 app/models/incline/user_login_history.rb
incline-0.2.28 app/models/incline/user_login_history.rb
incline-0.2.27 app/models/incline/user_login_history.rb