Class: NextSgad::ApplicationRecord
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- NextSgad::ApplicationRecord
show all
- Defined in:
- app/models/next_sgad/application_record.rb
Direct Known Subclasses
Activity, Assessment, Attendance, Configuration, Department, Employee, EmployeeAssessment, EmployeeGoal, EmployeeGoalActivity, EmployeeMessage, Function, Goal, GoalUnit, Justification, Message, Position, Result, Setting
Instance Method Summary
collapse
Instance Method Details
#create_number ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'app/models/next_sgad/application_record.rb', line 6
def create_number
tipo = self.class.name
return unless tipo.eql?(NextSgad::Position.name) || tipo.eql?(NextSgad::Employee.name) || tipo.eql?(NextSgad::Department.name) || tipo.eql?(NextSgad::Function.name)
i = self.class.all.map{|i| i.number.to_s.gsub(/\D/, '').to_i}.compact.sort.last || 0
i = i + 1
return unless number.blank?
self.number = "#{self.class::INITIAL_LETTER}#{i.to_s.rjust(8, '0')}"
end
|
#create_number! ⇒ Object
15
16
17
18
|
# File 'app/models/next_sgad/application_record.rb', line 15
def create_number!
self.create_number
self.save
end
|