From d9a887b90505bf2be9e17a3c5bd8ab7204aeff5a Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Sat, 9 Jan 2016 23:13:55 -0700 Subject: [PATCH] CreateTable supports all PG-specific columns even under Rails 4.0 Successive versions of Rails provided explicit support for more column types such as `money` and `uuid`. However, the ability to create a Postgres table with one of these column type is really dependent on which Postgres version you're using, and not which Rails version you're using -- all you have to do is use `t.column` rather than e.g., `t.money`, `t.uuid`, etc. --- spec/support/unit/active_record/create_table.rb | 9 +-------- .../unit/model_creation_strategies/active_record.rb | 2 -- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/spec/support/unit/active_record/create_table.rb b/spec/support/unit/active_record/create_table.rb index 67e9f571..65bcc528 100644 --- a/spec/support/unit/active_record/create_table.rb +++ b/spec/support/unit/active_record/create_table.rb @@ -47,14 +47,7 @@ module UnitTests column_options = {} end - begin - table.__send__(column_type, column_name, column_options) - rescue NoMethodError - raise ColumnNotSupportedError.new( - "#{Tests::Database.instance.adapter_class} does not support " + - ":#{column_type} columns." - ) - end + table.column(column_name, column_type, column_options) end end end diff --git a/spec/support/unit/model_creation_strategies/active_record.rb b/spec/support/unit/model_creation_strategies/active_record.rb index ce60e0e2..f9e268b4 100644 --- a/spec/support/unit/model_creation_strategies/active_record.rb +++ b/spec/support/unit/model_creation_strategies/active_record.rb @@ -72,8 +72,6 @@ module UnitTests def whitelist_attributes? options.fetch(:whitelist_attributes, true) end - - ColumnNotSupportedError = Class.new(StandardError) end end end