Class: Profile

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

Instance Method Summary collapse

Instance Method Details

#ageObject



39
40
41
42
43
# File 'app/models/profile.rb', line 39

def age
  return nil if self.birthday.blank? 
  now = Time.now.utc.to_date
  now.year - self.birthday.year - (self.birthday.to_date.change(:year => now.year) > now ? 1 : 0)
end

#birthday=(value) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/profile.rb', line 20

def birthday=(value)
  
  puts "He entrado en el metodo birthday con un :" + value.class.to_s 
        
  if value.blank?
    @birthday_formatted_invalid = false    
    super value
  else
    begin
      #super Date.parse(value)
      super value
      @birthday_formatted_invalid = false
    rescue 
      @birthday_formatted_invalid = true
    end
  end

end

#subjectObject

The subject of this profile



46
47
48
# File 'app/models/profile.rb', line 46

def subject
  actor.try(:subject)
end