File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -501,8 +501,25 @@ irb> device.id
501
501
=> " 814865cd-5a1d-4771-9306-4268f188fe9e"
502
502
```
503
503
504
- NOTE: ` gen_random_uuid() ` (from ` pgcrypto ` ) is assumed if no ` :default ` option was
505
- passed to ` create_table ` .
504
+ NOTE: ` gen_random_uuid() ` (from ` pgcrypto ` ) is assumed if no ` :default ` option
505
+ was passed to ` create_table ` .
506
+
507
+ To use the Rails model generator for a table using UUID as the primary key, pass
508
+ ` --primary-key-type=uuid ` to the model generator.
509
+
510
+ For example:
511
+
512
+ ``` ruby
513
+ rails generate model Device -- primary- key- type= uuid kind: string
514
+ ```
515
+
516
+ When building a model with a foreign key that will reference this UUID, treat
517
+ ` uuid ` as the native field type, for example:
518
+
519
+ ``` ruby
520
+ rails generate model Case device_id: uuid
521
+ ```
522
+
506
523
507
524
Generated Columns
508
525
-----------------
You can’t perform that action at this time.
0 commit comments