Class: UserProfile
  
  
  
  
  
    - Inherits:
 
    - 
      ApplicationRecord
      
        
        show all
      
    
 
  
  
  
  
  
      - Extended by:
 
      - ActiveHash::Associations::ActiveRecordExtensions
 
  
  
  
  
  
  
  
  
    - Defined in:
 
    - app/models/user_profile.rb
 
  
  
 
Overview
  
    This model is used to keep most of the information related to the user
identity and role, in order to keep the User model as empty as possible.
The User model only contains fields and associations that are strictly
related to authentication.
   
 
  
  Instance Attribute Summary collapse
  
  
    
    
  
    
      Delegated Instance Attributes
      collapse
    
    
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  
  ransackable_associations, ransackable_attributes
  
  
    Instance Attribute Details
    
      
      
      
  
  
    #birthday  ⇒ Date 
  
  
  
  
    
      
233 
     | 
    
      # File 'db/schema.rb', line 233
t.date "birthday" 
     | 
  
 
    
      
      
      
  
  
    #blog  ⇒ String 
  
  
  
  
    
      
235 
     | 
    
      # File 'db/schema.rb', line 235
t.string "blog" 
     | 
  
 
    
      
      
      
  
  
    #country_code  ⇒ String 
  
  
  
  
    
      
227 
     | 
    
      # File 'db/schema.rb', line 227
t.string "country_code" 
     | 
  
 
    
      
      
      
  
  
    #created_at  ⇒ DateTime 
  
  
  
  
    
      
228 
     | 
    
      # File 'db/schema.rb', line 228
t.datetime "created_at" 
     | 
  
 
    
      
      
      
  
  
    #description  ⇒ String 
  
  
  
  
    
      
231 
     | 
    
      # File 'db/schema.rb', line 231
t.string "description" 
     | 
  
 
    
      
      
      
  
  
    #full_name  ⇒ String 
  
  
  
  
    
      
225 
     | 
    
      # File 'db/schema.rb', line 225
t.string "full_name" 
     | 
  
 
    
      
      
      
  
  
    #location  ⇒ String 
  
  
  
  
    
      
232 
     | 
    
      # File 'db/schema.rb', line 232
t.string "location" 
     | 
  
 
    
      
      
      
  
  
    #passport  ⇒ String 
  
  
  
  
    
      
236 
     | 
    
      # File 'db/schema.rb', line 236
t.string "passport" 
     | 
  
 
    
      
      
      
  
  
    #phone_number  ⇒ String 
  
  
  
  
    
      
226 
     | 
    
      # File 'db/schema.rb', line 226
t.string "phone_number" 
     | 
  
 
    
      
      
      
  
  
    #postal_address  ⇒ String 
  
  
  
  
    
      
239 
     | 
    
      # File 'db/schema.rb', line 239
t.string "postal_address" 
     | 
  
 
    
      
      
      
  
  
    #role_id  ⇒ Object  
  
  
  
  
    
      
21 
     | 
    
      # File 'app/models/user_profile.rb', line 21
validates :role_id, presence: true 
     | 
  
 
    
      
      
      
  
  
    #second_phone_number  ⇒ String 
  
  
  
  
    
      
230 
     | 
    
      # File 'db/schema.rb', line 230
t.string "second_phone_number" 
     | 
  
 
    
      
      
      
  
  
    #updated_at  ⇒ DateTime 
  
  
  
  
    
      
229 
     | 
    
      # File 'db/schema.rb', line 229
t.datetime "updated_at" 
     | 
  
 
    
      
      
      
  
  
    #website  ⇒ String 
  
  
  
  
    
      
234 
     | 
    
      # File 'db/schema.rb', line 234
t.string "website" 
     | 
  
 
    
      
      
      
  
  
    #zip_code  ⇒ String 
  
  
  
  
    
      
238 
     | 
    
      # File 'db/schema.rb', line 238
t.string "zip_code" 
     | 
  
 
    
   
  
    Class Method Details
    
      
  
  
    .with_role  ⇒ ActiveRecord::Relation<UserProfile> 
  
  
  
  
    A relation of UserProfiles that are with role. Active Record Scope
   
 
  
    
      
25
26
27
28
29
30
31 
     | 
    
      # File 'app/models/user_profile.rb', line 25
scope :with_role, lambda { |role|
  if role.is_a?(UserRole)
    where(role_id: role.id)
  else
    where(role_id: UserRole.find_by_name(role.to_s).id)
  end
}
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #missing_fields  ⇒ Hash 
  
  
  
  
    List of fields that are required for processing reimbursements but are
not present. The list of fields is set as a configuration parameter for
the application.
   
 
  
    
      
43
44
45
46
47 
     | 
    
      # File 'app/models/user_profile.rb', line 43
def missing_fields
  fields = Rails.configuration.site['relevant_profile_fields']
  fields = fields.select { |f| send(f.to_sym).blank? }
  Hash[fields.map { |f| [f, self.class.human_attribute_name(f)] }]
end
     | 
  
 
    
      
  
  
    #role_name  ⇒ Object 
  
  
  
  
    
      
19 
     | 
    
      # File 'app/models/user_profile.rb', line 19
delegate :name, to: :role, prefix: true, allow_nil: true 
     | 
  
 
    
      
  
  
    #set_default_attrs  ⇒ Object 
  
  
  
  
    
      
33
34
35 
     | 
    
      # File 'app/models/user_profile.rb', line 33
def set_default_attrs
  self.role_name ||= 'none'
end 
     | 
  
 
    
      
  
  
    The associated user (one to one association)
   
 
  
    
      
13 
     | 
    
      # File 'app/models/user_profile.rb', line 13
belongs_to :user 
     |