Joao Silva wrote:
> Hi,
> 
> I have one field that needs to be incremented automatically, but be
> scoped to another column. So it should increment based on the last value
> of the previous row with the same value of the scoped column.

Remember to figure out how it will behave with deleted records.

> 
> I'm not trying to replace ID with another primary key or anything crazy
> like that, just trying to auto-increment a database column!
> 
> Any idea of how to do this? Rails 3. Thanks!

acts_as_list might actually be useful here -- it does more or less this 
same thing with the position column.

Some databases can do this on the DB side.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to