From fa0aebf320995a598c5bffda729aed4429681f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 3 Nov 2012 13:26:21 -0200 Subject: Check if the options value is present before to send the deprecation message --- .../connection_adapters/abstract/schema_statements.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'activerecord/lib') 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 73aaffc146..17dd71e898 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -629,11 +629,13 @@ module ActiveRecord index_options = options[:where] ? " WHERE #{options[:where]}" : "" end else - message = "Passing a string as third argument of `add_index` is deprecated and will" + - " be removed in Rails 4.1." + - " Use add_index(#{table_name.inspect}, #{column_name.inspect}, unique: true) instead" + if options + message = "Passing a string as third argument of `add_index` is deprecated and will" + + " be removed in Rails 4.1." + + " Use add_index(#{table_name.inspect}, #{column_name.inspect}, unique: true) instead" - ActiveSupport::Deprecation.warn message + ActiveSupport::Deprecation.warn message + end index_type = options end -- cgit v1.2.3