Class: User
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- User
- Defined in:
- app/models/user.rb
Overview
Instance Attribute Summary collapse
-
#admin ⇒ Boolean
- true
-
if User is an admin.
-
#confirmation_sent_at ⇒ DateTime
When the confirmation email was sent.
-
#confirmation_token ⇒ String
Confirmation token to check email.
-
#confirmed_at ⇒ DateTime
When email is confirmed.
-
#created_at ⇒ DateTime
When the record was created.
-
#current_sign_in_at ⇒ DateTime
Time of current sign in.
-
#current_sign_in_ip ⇒ Inet
Ip of current sign in.
-
#editor ⇒ Boolean
- true
-
if User is an editor.
-
#email ⇒ String
Unique contact and login name for User.
-
#faileds_attempts ⇒ Integer
Number of failed login recived.
-
#id ⇒ Integer
Unique identifier for User.
-
#last_sign_in_at ⇒ DateTime
Time of last sign in.
-
#last_sign_in_ip ⇒ Inet
Ip of last sign in.
-
#locked_at ⇒ DateTime
When User was locked.
-
#sign_in_count ⇒ Integer
Sign in count for User, default is 0, null is false.
-
#unconfirmed_email ⇒ String
Address to check before an email chand.
-
#unlock_tocken ⇒ String
Tocken to unlock an User.
-
#updated_at ⇒ DateTime
When the record was updated.
Instance Method Summary collapse
-
#avatar_url ⇒ String
Gravatar url for user.
Instance Attribute Details
#admin ⇒ Boolean
Returns [true] if User is an admin.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#confirmation_sent_at ⇒ DateTime
Returns when the confirmation email was sent.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#confirmation_token ⇒ String
Returns confirmation token to check email.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#confirmed_at ⇒ DateTime
Returns when email is confirmed.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#created_at ⇒ DateTime
Returns when the record was created.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#current_sign_in_at ⇒ DateTime
Returns Time of current sign in.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#current_sign_in_ip ⇒ Inet
Returns ip of current sign in.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#editor ⇒ Boolean
Returns [true] if User is an editor.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#email ⇒ String
Returns unique contact and login name for User.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#faileds_attempts ⇒ Integer
Returns number of failed login recived.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#id ⇒ Integer
Returns unique identifier for User.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#last_sign_in_at ⇒ DateTime
Returns Time of last sign in.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#last_sign_in_ip ⇒ Inet
Returns ip of last sign in.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#locked_at ⇒ DateTime
Returns when User was locked.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#sign_in_count ⇒ Integer
Returns sign in count for User, default is 0, null is false.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#unconfirmed_email ⇒ String
Returns address to check before an email chand.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#unlock_tocken ⇒ String
Returns tocken to unlock an User.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
#updated_at ⇒ DateTime
Returns when the record was updated.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/user.rb', line 45 class User < ApplicationRecord # Include default devise modules. Others available are: # :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :timeoutable, :trackable, :lockable has_many :tickets, dependent: :destroy has_and_belongs_to_many :groups has_many :events, through: :groups scope :editors, -> { where editor: true } scope :admins, -> { where admin: true } # @return [String] gravatar url for user def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end end |
Instance Method Details
#avatar_url ⇒ String
Returns gravatar url for user.
59 60 61 62 |
# File 'app/models/user.rb', line 59 def avatar_url hash = Digest::MD5.hexdigest(email) "https://www.gravatar.com/avatar/#{hash}?s=64i&d=identicon" end |