I need to do the following in rails:
I have a string with the following composition: AAA-BBB-2008-000001
The first to groups are strings, named @string1 and @string2. The
third is the year, (reflected using Time.now.strftime("%Y")) and the
last part is an integer, @integer1.
I'm using a PostgreSQL 8 database and I need to put that composition
on a string.I have no problem with the string variables and the year.
The catch here is the integer, it increases everytime I do a new
registry and, when a new year comes, it resets to 1. More over, I need
the integer to be 6-digit.I don't know how to do that, but I know the
logic of th increments:
When the integer is 10, I need it to be 000010; when it's 100, 000100;
1000 => 001000 and so on.
And let's suppose one of our string changes, for example. It also must
resets the integer to 1.
As you can see, it's a unique composition.
As the id from the database keeps increasing, that number won't work
on me. I need to set it apart, without using that number. And that
count must be kept, whenever I log in to my app.
Is it hard to do this stuff?