Class: User

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#confirmation_sent_atDateTime

used by Devise Confirmable

Returns:

  • (DateTime)

    the current value of confirmation_sent_at


28
29
30
# File 'app/models/user.rb', line 28

def confirmation_sent_at
  @confirmation_sent_at
end

#confirmation_tokenString

used by Devise Confirmable

Returns:

  • (String)

    the current value of confirmation_token


28
29
30
# File 'app/models/user.rb', line 28

def confirmation_token
  @confirmation_token
end

#confirmed_atDateTime

used by Devise Confirmable

Returns:

  • (DateTime)

    the current value of confirmed_at


28
29
30
# File 'app/models/user.rb', line 28

def confirmed_at
  @confirmed_at
end

#created_atDateTime

Returns the current value of created_at

Returns:

  • (DateTime)

    the current value of created_at


28
29
30
# File 'app/models/user.rb', line 28

def created_at
  @created_at
end

#current_sign_in_atDateTime

used by Devise trackable

Returns:

  • (DateTime)

    the current value of current_sign_in_at


28
29
30
# File 'app/models/user.rb', line 28

def 
  @current_sign_in_at
end

#current_sign_in_ipString

used by Devise trackable

Returns:

  • (String)

    the current value of current_sign_in_ip


28
29
30
# File 'app/models/user.rb', line 28

def 
  @current_sign_in_ip
end

#emailString

the default column used for database authentication

Returns:

  • (String)

    the current value of email


28
29
30
# File 'app/models/user.rb', line 28

def email
  @email
end

#encrypted_passwordString

used by Devise

Returns:

  • (String)

    the current value of encrypted_password


28
29
30
# File 'app/models/user.rb', line 28

def encrypted_password
  @encrypted_password
end

#imageString

a url to an avatar - not currently in use

Returns:

  • (String)

    the current value of image


28
29
30
# File 'app/models/user.rb', line 28

def image
  @image
end

#invitation_accepted_atDateTime

used by Devise Invitable

Returns:

  • (DateTime)

    the current value of invitation_accepted_at


28
29
30
# File 'app/models/user.rb', line 28

def invitation_accepted_at
  @invitation_accepted_at
end

#invitation_created_atDateTime

used by Devise Invitable

Returns:

  • (DateTime)

    the current value of invitation_created_at


28
29
30
# File 'app/models/user.rb', line 28

def invitation_created_at
  @invitation_created_at
end

#invitation_limitInteger

used by Devise Invitable

Returns:

  • (Integer)

    the current value of invitation_limit


28
29
30
# File 'app/models/user.rb', line 28

def invitation_limit
  @invitation_limit
end

#invitation_sent_atDateTime

used by Devise Invitable

Returns:

  • (DateTime)

    the current value of invitation_sent_at


28
29
30
# File 'app/models/user.rb', line 28

def invitation_sent_at
  @invitation_sent_at
end

#invitation_tokenString

used by Devise Invitable

Returns:

  • (String)

    the current value of invitation_token


28
29
30
# File 'app/models/user.rb', line 28

def invitation_token
  @invitation_token
end

#invitations_countInteger

used by Devise Invitable

Returns:

  • (Integer)

    the current value of invitations_count


28
29
30
# File 'app/models/user.rb', line 28

def invitations_count
  @invitations_count
end

#invited_by_idInteger

used by Devise Invitable

Returns:

  • (Integer)

    the current value of invited_by_id


28
29
30
# File 'app/models/user.rb', line 28

def invited_by_id
  @invited_by_id
end

#invited_by_typeString

used by Devise Invitable

Returns:

  • (String)

    the current value of invited_by_type


28
29
30
# File 'app/models/user.rb', line 28

def invited_by_type
  @invited_by_type
end

#last_sign_in_atDateTime

used by Devise trackable

Returns:

  • (DateTime)

    the current value of last_sign_in_at


28
29
30
# File 'app/models/user.rb', line 28

def 
  @last_sign_in_at
end

#last_sign_in_ipString

used by Devise trackable

Returns:

  • (String)

    the current value of last_sign_in_ip


28
29
30
# File 'app/models/user.rb', line 28

def 
  @last_sign_in_ip
end

#nicknameString

allows users to display something else than their email

Returns:

  • (String)

    the current value of nickname


28
29
30
# File 'app/models/user.rb', line 28

def nickname
  @nickname
end

#remember_created_atDateTime

used by Devise

Returns:

  • (DateTime)

    the current value of remember_created_at


28
29
30
# File 'app/models/user.rb', line 28

def remember_created_at
  @remember_created_at
end

#reset_password_sent_atDateTime

used by Devise

Returns:

  • (DateTime)

    the current value of reset_password_sent_at


28
29
30
# File 'app/models/user.rb', line 28

def reset_password_sent_at
  @reset_password_sent_at
end

#reset_password_tokenString

used by Devise

Returns:

  • (String)

    the current value of reset_password_token


28
29
30
# File 'app/models/user.rb', line 28

def reset_password_token
  @reset_password_token
end

#sign_in_countInteger

used by Devise trackable

Returns:

  • (Integer)

    the current value of sign_in_count


28
29
30
# File 'app/models/user.rb', line 28

def 
  @sign_in_count
end

#slugString

URL friendly version of name that can be used as a route param

Returns:

  • (String)

    the current value of slug


28
29
30
# File 'app/models/user.rb', line 28

def slug
  @slug
end

#timezoneString

Returns the current value of timezone

Returns:

  • (String)

    the current value of timezone


28
29
30
# File 'app/models/user.rb', line 28

def timezone
  @timezone
end

#updated_atDateTime

Returns the current value of updated_at

Returns:

  • (DateTime)

    the current value of updated_at


28
29
30
# File 'app/models/user.rb', line 28

def updated_at
  @updated_at
end

Class Method Details

.create_from_omniauth(params) ⇒ Object


55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/user.rb', line 55

def self.create_from_omniauth(params)
  info = params[:info]

  create do |user|
      user.email    = info[:email]
      user.image    = info[:image]
      user.nickname = info[:nickname]
      user.password = Devise.friendly_token
      user.confirmed_at = Time.now
  end
end

Instance Method Details

#should_generate_new_friendly_id?boolean

Returns:

  • (boolean)

74
75
76
77
78
79
80
# File 'app/models/user.rb', line 74

def should_generate_new_friendly_id?
  if !slug?
    nickname_changed?
  else
    false
  end
end

#to_local_time(time) ⇒ Object


86
87
88
89
# File 'app/models/user.rb', line 86

def to_local_time(time)
  @_timezone = Timezone::Zone.new( zone: ActiveSupport::TimeZone::MAPPING[timezone] ) if @_timezone.nil?
  @_timezone.time(time)
end

#update_from_omniauth(params) ⇒ Object


67
68
69
70
71
# File 'app/models/user.rb', line 67

def update_from_omniauth(params)
  if params[:info].key?(:image)
    @image = params[:info][:image]
  end
end

#valid_timezoneObject


82
83
84
# File 'app/models/user.rb', line 82

def valid_timezone
  errors.add(:timezone, "#{timezone} is not a valid zone name") unless ActiveSupport::TimeZone::MAPPING.has_key?(timezone)
end