That one 00012018 that you want does not need to be persisted, and can be used only for visualization. To do this, you can implement a method in the model.
class Inscricao < ApplicationRecord
  def numero_inscricao
    return nil unless self.persisted?
    id_com_zeros = "%04d" % self.id
    "#{id_com_zeros}#{self.created_at.year}"
  end
end
That’ll give you:
foo.numero_inscricao
=> "00012018"
How he uses the #created_at, will work for the next years and for the records that are already in the bank, for being a function executed in memory.
Just make sure that the ID is an integer and not a UUID, as is possible.
							
							
						 
Give more information, such as codes you have tried so far.
– David Alves
You will need to identify what the pattern is in the registration number. In the number you have placed there are 8 characters, then there is a number (1) and then there is the year(2018). Here you will contact this information.
– Danilo Cândido