diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-14 23:22:35 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-14 23:22:35 -0700 |
commit | 5e0e4152b69a3de1b7e8c063368bf8d06d162834 (patch) | |
tree | 62b5a854d7903093114cb90000bb5ac6047e8213 /activerecord | |
parent | aac00ed9c5a54d583d5177a019debf567639e018 (diff) | |
download | rails-5e0e4152b69a3de1b7e8c063368bf8d06d162834.tar.gz rails-5e0e4152b69a3de1b7e8c063368bf8d06d162834.tar.bz2 rails-5e0e4152b69a3de1b7e8c063368bf8d06d162834.zip |
clean up pk delclaration in `create_table`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index b8b2cf9ab1..cd4409295f 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -172,7 +172,14 @@ module ActiveRecord # See also TableDefinition#column for details on how to create columns. def create_table(table_name, options = {}) td = create_table_definition - td.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false + + unless options[:id] == false + pk = options.fetch(:primary_key) { + Base.get_primary_key table_name.to_s.singularize + } + + td.primary_key pk + end yield td if block_given? |