diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-26 17:37:26 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-26 17:37:26 -0300 |
commit | baf62e531686ee157746d239037be121f8191275 (patch) | |
tree | 9a36d489ac638d7c35e885abc8cd3b18d566cb3c | |
parent | fb522a27731e04d149abe68809fa030382931bc3 (diff) | |
download | rails-baf62e531686ee157746d239037be121f8191275.tar.gz rails-baf62e531686ee157746d239037be121f8191275.tar.bz2 rails-baf62e531686ee157746d239037be121f8191275.zip |
Invert the conditionals to make easier to read
Also improve some of the code conventions
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 8 |
1 files changed, 4 insertions, 4 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 23404a5c48..b59d263dfa 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -186,10 +186,10 @@ module ActiveRecord def create_table(table_name, options = {}) td = create_table_definition table_name, options[:temporary], options[:options], options[:as] - unless options[:id] == false || options[:as] - pk = options.fetch(:primary_key) { + if options[:id] != false && !options[:as] + pk = options.fetch(:primary_key) do Base.get_primary_key table_name.to_s.singularize - } + end td.primary_key pk, options.fetch(:id, :primary_key), options end @@ -201,7 +201,7 @@ module ActiveRecord end result = execute schema_creation.accept td - td.indexes.each_pair { |c,o| add_index table_name, c, o } unless supports_indexes_in_create? + td.indexes.each_pair { |c, o| add_index(table_name, c, o) } unless supports_indexes_in_create? result end |