Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve docs for postgresql with uuid primary keys [ci skip]

Introduced in 09ac177.
  • Loading branch information...
commit 14a75a54a802b35db5a7802eca90dae9aa8e3518 1 parent 8a7c2e1
@carlosantoniodasilva carlosantoniodasilva authored
View
15 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -340,10 +340,10 @@ class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
# end
#
# By default, this will use the +uuid_generate_v4()+ function from the
- # +uuid-ossp+ extension, which MUST be enabled on your databse. To enable
+ # +uuid-ossp+ extension, which MUST be enabled on your database. To enable
# the +uuid-ossp+ extension, you can use the +enable_extension+ method in your
- # migrations To use a UUID primary key without +uuid-ossp+ enabled, you can
- # set the +:default+ option to nil:
+ # migrations. To use a UUID primary key without +uuid-ossp+ enabled, you can
+ # set the +:default+ option to +nil+:
#
# create_table :stuffs, id: false do |t|
# t.primary_key :id, :uuid, default: nil
@@ -354,11 +354,10 @@ class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
# You may also pass a different UUID generation function from +uuid-ossp+
# or another library.
#
- # Note that setting the UUID primary key default value to +nil+
- # will require you to assure that you always provide a UUID value
- # before saving a record (as primary keys cannot be nil). This might be
- # done via the SecureRandom.uuid method and a +before_save+ callback,
- # for instance.
+ # Note that setting the UUID primary key default value to +nil+ will
+ # require you to assure that you always provide a UUID value before saving
+ # a record (as primary keys cannot be +nil+). This might be done via the
+ # +SecureRandom.uuid+ method and a +before_save+ callback, for instance.
def primary_key(name, type = :primary_key, options = {})
return super unless type == :uuid
options[:default] = options.fetch(:default, 'uuid_generate_v4()')
View
1  activerecord/test/cases/adapters/postgresql/uuid_test.rb
@@ -59,7 +59,6 @@ class UUID < ActiveRecord::Base
def setup
@connection = ActiveRecord::Base.connection
-
@connection.reconnect!
@connection.transaction do
Please sign in to comment.
Something went wrong with that request. Please try again.