I am building api in rails and I am wondering what is the best way to implement object ids. I don’t want to use database generated id.
This article API with Ruby on Rails: useful tricks | Railsware Blog suggests using guid, but I don’t like the format I would prefer ids similar to parse api. Are there any gems that do this or should I just use securerandom and catch duplicates?
Can anyone point to some good articles or share some tips, best practices about implementing api in rails?
Format aside, a modern UUID saves you the practical trouble of duplicates:
Rails 4 features (decent) support for (type IV) UUID as primary key, so you can just skip to that and avoid integers completely on that table if it’s easier.
Mostly because of the enumeration problem, that some can guess number of records just by looking at id values. Or guess ids of objects from other users and so on.