Class: User

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

Overview

Schema Information

Table name: users

id                     :integer          not null, primary key
email                  :string(255)      default(""), not null
encrypted_password     :string(255)      default(""), not null
reset_password_token   :string(255)
reset_password_sent_at :datetime
remember_created_at    :datetime
sign_in_count          :integer          default(0)
current_sign_in_at     :datetime
last_sign_in_at        :datetime
current_sign_in_ip     :string(255)
last_sign_in_ip        :string(255)
password_salt          :string(255)
confirmation_token     :string(255)
confirmed_at           :datetime
confirmation_sent_at   :datetime
unconfirmed_email      :string(255)
failed_attempts        :integer          default(0)
unlock_token           :string(255)
locked_at              :datetime
authentication_token   :string(255)
created_at             :datetime         not null
updated_at             :datetime         not null
gender                 :boolean
position               :string(255)
firstname              :string(255)
lastname               :string(255)
function               :string(255)
phone                  :string(255)
fax                    :string(255)
facebook               :string(255)
twitter                :string(255)
linkedin               :string(255)
xing                   :string(255)
googleplus             :string(255)
enable_expert_mode     :boolean          default(TRUE)

Instance Method Summary collapse

Instance Method Details

#anredeObject



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/models/user.rb', line 76

def anrede
  if self.lastname == "n.v."
    r = "Sehr geehrte Damen und Herren"
  else
    if self.gender == true
      r = "Sehr geehrter Herr"
    else
      r = "Sehr geehrte Frau"
    end
    r << " #{self.lastname}"
  end
  return r
end

#gender_anredeObject



94
95
96
97
98
99
100
# File 'app/models/user.rb', line 94

def gender_anrede
  if self.gender == true
    "Sehr geehrter Herr"
  else
    "Sehr geehrte Frau"
  end
end

#has_role?(name) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
71
72
73
74
# File 'app/models/user.rb', line 68

def has_role?(name)
  if name.class == Array
    ( self.roles & Goldencobra::Role.where(name: name) ).any?
  else
    self.roles.include?(Goldencobra::Role.find_by_name(name))
  end
end

#titleObject



90
91
92
# File 'app/models/user.rb', line 90

def title
  "#{self.firstname} #{self.lastname}"
end