阅读背景:

在rails中生成一个自动增量字段

来源:互联网 

I have a model Token, which has a field token_number that I need to auto increment (starting from 1001), if and only if the user does not provide it. The problem is that, since the user has the option to provide this field, I can't exactly query the database and ask for the largest token_number. I found one answer on this forum, but I'm quite certain there has to be a better way to do it than to execute an SQL statement? I have a model Token, which has a field token_n




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: