Writing a simple incrementing counter in rails

Posted by Trip on Stack Overflow See other posts from Stack Overflow or by Trip
Published on 2010-06-14T17:27:57Z Indexed on 2010/06/14 18:12 UTC
Read the original article Hit count: 258

For every Card, I would like to attach a special number to them that increments by one.

I assume I can do this all in the controller.

def create
 @card = Card.new(params[:card])
 @card.SpecNum = @card.SpecNum ++
...
end

Or. I can be blatantly retarded. And maybe the best bet is to add an auto-incremement table to mysql. The problem is the number has to start at a specific number, 1020.

Any ideas?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about ruby-on-rails