Class: User
- Inherits:
-
ApplicationRecord
show all
- Extended by:
- ActiveHash::Associations::ActiveRecordExtensions
- Defined in:
- app/models/user.rb
Overview
Devise user.
This model only keeps the information and methods needed for authentication.
For user information or role, use UserProfile
Instance Attribute Summary collapse
-
#profile ⇒ UserProfile
Setup accessible (or protected) attributes for your model Associated object with all information not directly related to authentication.
Class Method Summary
collapse
Instance Method Summary
collapse
ransackable_associations, ransackable_attributes
Instance Attribute Details
#created_at ⇒ DateTime
255
|
# File 'db/schema.rb', line 255
t.datetime "created_at"
|
#current_sign_in_at ⇒ DateTime
249
|
# File 'db/schema.rb', line 249
t.datetime "current_sign_in_at"
|
#current_sign_in_ip ⇒ String
251
|
# File 'db/schema.rb', line 251
t.string "current_sign_in_ip"
|
#email ⇒ String
243
|
# File 'db/schema.rb', line 243
t.string "email", default: "", null: false
|
#encrypted_password ⇒ String
244
|
# File 'db/schema.rb', line 244
t.string "encrypted_password", default: "", null: false
|
#last_sign_in_at ⇒ DateTime
250
|
# File 'db/schema.rb', line 250
t.datetime "last_sign_in_at"
|
#last_sign_in_ip ⇒ String
252
|
# File 'db/schema.rb', line 252
t.string "last_sign_in_ip"
|
#locale ⇒ String
254
|
# File 'db/schema.rb', line 254
t.string "locale", default: "en", null: false
|
#nickname ⇒ String
Validations:
39
|
# File 'app/models/user.rb', line 39
validates :nickname, presence: true
|
#remember_created_at ⇒ DateTime
247
|
# File 'db/schema.rb', line 247
t.datetime "remember_created_at"
|
#reset_password_sent_at ⇒ DateTime
246
|
# File 'db/schema.rb', line 246
t.datetime "reset_password_sent_at"
|
#reset_password_token ⇒ String
245
|
# File 'db/schema.rb', line 245
t.string "reset_password_token"
|
#sign_in_count ⇒ Integer
248
|
# File 'db/schema.rb', line 248
t.integer "sign_in_count", default: 0
|
#updated_at ⇒ DateTime
256
|
# File 'db/schema.rb', line 256
t.datetime "updated_at"
|
Class Method Details
.for_ichain_username(username, attributes) ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'app/models/user.rb', line 53
def self.for_ichain_username(username, attributes)
if user = find_by_nickname(username)
where(id: user.id).update_all(email: attributes[:email]) if user.email != attributes[:email]
else
user = create(nickname: username, email: attributes[:email])
end
user
end
|
.with_role(role) ⇒ Object
49
50
51
|
# File 'app/models/user.rb', line 49
def self.with_role(role)
UserProfile.with_role(role).map(&:user)
end
|
Instance Method Details
#event_emails ⇒ ActiveRecord::Relation<EventEmail>
Event Emails send by a user
31
|
# File 'app/models/user.rb', line 31
has_many :event_emails
|
#event_organizers ⇒ ActiveRecord::Relation<EventOrganizer>
Event organizer for events
33
|
# File 'app/models/user.rb', line 33
has_many :event_organizers
|
#find_profile ⇒ Object
45
46
47
|
# File 'app/models/user.rb', line 45
def find_profile
profile || create_profile
end
|
#organizing_events ⇒ ActiveRecord::Relation<OrganizingEvent>
Events for which the user is an event organizer
35
|
# File 'app/models/user.rb', line 35
has_many :organizing_events, through: :event_organizers, source: :event
|
Setup accessible (or protected) attributes for your model
Associated object with all information not directly related to authentication
23
|
# File 'app/models/user.rb', line 23
has_one :profile, class_name: 'UserProfile'
|
#reimbursements ⇒ ActiveRecord::Relation<Reimbursement>
Reimbursements created by the user
27
|
# File 'app/models/user.rb', line 27
has_many :reimbursements, inverse_of: :user
|
#requests ⇒ ActiveRecord::Relation<Request>
Requests created by the user
25
|
# File 'app/models/user.rb', line 25
has_many :requests, inverse_of: :user
|
#state_changes ⇒ ActiveRecord::Relation<StateChange>
State changes (transitions or manual adjustments) performed by the user
29
|
# File 'app/models/user.rb', line 29
has_many :state_changes, inverse_of: :user
|
#title ⇒ Object
41
42
43
|
# File 'app/models/user.rb', line 41
def title
nickname
end
|