Commit 18eb2d0b by Brent Walther

Fix fatal error when using `annotate` with ActiveRecord 4.2

The fatal error was introduced with commit fc31d85. The method `supports_foreign_keys?` is only available on ActiveRecord versions >= 4.2. Fixes issue 316.
parent b319409c
......@@ -321,7 +321,8 @@ module AnnotateModels
fk_info = "#\n# Foreign Keys\n#\n"
end
return '' unless klass.connection.supports_foreign_keys? && klass.connection.respond_to?(:foreign_keys)
return '' unless klass.connection.respond_to?(:supports_foreign_keys?) &&
klass.connection.supports_foreign_keys? && klass.connection.respond_to?(:foreign_keys)
foreign_keys = klass.connection.foreign_keys(klass.table_name)
return '' if foreign_keys.empty?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment