I need when a new product is created it generates a number ex: 0001/2015 number / year_vigente and when change of year returns to zero.
I made a helper just to format the number in the views, but it does not solve the problem of automatic generation and renewal next year.
def format_product_number(product_code)
format_product = product_code[0..4]
format_product << "/#{Time.now.year}"
format_product
end
I have a form with a field:
@product
<%= f.label :product_number %>
<%= f.number_field :product_number %>
Does anyone know a way to do this?