Rails gives values of table ids as int开发者_JAVA技巧egers. It starts from 1 and keeps increasing. How can I modify this default behavior? How can I make rails to generate a random string and pass it on as id for the tables?
It is strongly recommended you do NOT modify this behavior.
The whole point of using Rails is to use a whole lot of programming magic and goodies provided by the framework. These advantages will come on account of following all conventions Rails impose upon you.
Every time you wish to go a different route such as changing the nature of the table ids you should stop and think of a different solution to whatever problem you may have.
Learning Rails programming is about learning many of its conventions and aligning your programming style to them. For most of us this will have the added benefit of teaching us better coding techniques and upping our level.
Good luck to you.
精彩评论