Rails model with unique string field (Postgres)

UPDATE: Using a Postgres UUID field is a great way if you don’t care about the format of the unique field. See http://blog.arkency.com/2014/10/how-to-start-using-uuid-in-activerecord-with-postgresql/

About these ads

3 thoughts on “Rails model with unique string field (Postgres)

    • Thanks. I was hoping there is some built-in unique hash generation in postgres, that would be really nice. The PL/pgSQL approach is nice in case you expect collisions to happen often.

      Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s