C83 / THP_2.0

0 stars 0 forks source link

Add uuid as a key to SQL #5

Closed C83 closed 6 years ago

C83 commented 6 years ago

Why ?

Normal id in rails are incremental integers. The first Xxx ever created will have the id of 1, the next one of 2 etc… This way, it's really easy (for a hacker/bad person) to guess the url for the other resources. Using uuid as a primary key for each model will prevent this.

A uuid looks like this: 46c18abc-d96f-40da-a023-2ff0ed0bb6cf so your routes will look like: /models/46c18abc-d96f-40da-a023-2ff0ed0bb6cf

Todo

Follow this article. https://lab.io/articles/2017/04/13/uuids-rails-5-1/

C83 commented 6 years ago

Article followed and test done with success.