Class: Survey

Inherits:
ApplicationRecord show all
Defined in:
app/models/survey.rb

Overview

the survey model
very simple at this stage : a survey belongs to a user

Instance Method Summary collapse

Instance Method Details

#update_metasObject

updates the metas after a survey has been successfully sent to customer



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/survey.rb', line 16

def update_metas
  metas={}
  if self.metas
    metas=ActiveSupport::JSON.decode(self.metas)
    metas["sent"]+=1
  else
    metas["sent"]=1
  end
  self.metas=ActiveSupport::JSON.encode(metas)
  puts("*************adjusting surveys #{self.id} metas to #{self.metas}***************")
  if self.save
    result=true
  else
    result=false
  end
  result
end