you can use sprintf formatting for the integer:

 @integer1 = 10
 int_formatted = "%06d" % @integer1 # returns "000010"

I don't understand the other requirements enough to help further


On Nov 11, 6:21 pm, The Neurochild <[EMAIL PROTECTED]> wrote:
> Hello...
>
> 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?
>
> Greetings...
>
> The Neurochild
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to