Skip to content

Commit

Permalink
Fix bug with Rails 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Dec 27, 2018
1 parent 873e520 commit 2eaa65b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/active_record/annotate/dumper.rb
Expand Up @@ -2,11 +2,11 @@ module ActiveRecord
module Annotate
module Dumper
class << self
def dump(table_name, connection = ActiveRecord::Base.connection)
def dump(table_name, connection = ActiveRecord::Base.connection, config = ActiveRecord::Base)
string_io = StringIO.new

if connection.table_exists?(table_name)
dumper(connection).send(:table, table_name, string_io)
dumper(connection, config).send(:table, table_name, string_io)
else
string_io.write(" # can't find table `#{table_name}`")
end
Expand All @@ -15,8 +15,12 @@ def dump(table_name, connection = ActiveRecord::Base.connection)
end

private
def dumper(connection)
ActiveRecord::SchemaDumper.send(:new, connection)
def dumper(connection, config)
if connection.respond_to?(:create_schema_dumper)
connection.create_schema_dumper(ActiveRecord::SchemaDumper.send(:generate_options, config))
else
ActiveRecord::SchemaDumper.send(:new, connection)
end
end

def process_annotation(string_io)
Expand Down

0 comments on commit 2eaa65b

Please sign in to comment.