提交 b25933f2 编写于 作者: M Marcel Molina

Get rid of warnings generated by calling obsolete .to_a method on a Symbol

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2341 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 c5f53ca3
...@@ -54,12 +54,12 @@ def rename_column(table_name, column_name, new_column_name) ...@@ -54,12 +54,12 @@ def rename_column(table_name, column_name, new_column_name)
end end
# Create a new index on the given table. By default, it will be named # Create a new index on the given table. By default, it will be named
# <code>"#{table_name}_#{column_name.to_a.first}_index"</code>, but you # <code>"#{table_name}_#{Array(column_name).first}_index"</code>, but you
# can explicitly name the index by passing <code>:name => "..."</code> # can explicitly name the index by passing <code>:name => "..."</code>
# as the last parameter. Unique indexes may be created by passing # as the last parameter. Unique indexes may be created by passing
# <code>:unique => true</code>. # <code>:unique => true</code>.
def add_index(table_name, column_name, options = {}) def add_index(table_name, column_name, options = {})
index_name = "#{table_name}_#{column_name.to_a.first}_index" index_name = "#{table_name}_#{Array(column_name).first}_index"
if Hash === options # legacy support, since this param was a string if Hash === options # legacy support, since this param was a string
index_type = options[:unique] ? "UNIQUE" : "" index_type = options[:unique] ? "UNIQUE" : ""
...@@ -68,7 +68,7 @@ def add_index(table_name, column_name, options = {}) ...@@ -68,7 +68,7 @@ def add_index(table_name, column_name, options = {})
index_type = options index_type = options
end end
execute "CREATE #{index_type} INDEX #{index_name} ON #{table_name} (#{column_name.to_a.join(", ")})" execute "CREATE #{index_type} INDEX #{index_name} ON #{table_name} (#{Array(column_name).join(", ")})"
end end
# Remove the given index from the table. # Remove the given index from the table.
...@@ -134,4 +134,4 @@ def add_column_options!(sql, options) #:nodoc: ...@@ -134,4 +134,4 @@ def add_column_options!(sql, options) #:nodoc:
end end
end end
end end
end end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册