Skip to content

Instantly share code, notes, and snippets.

@remi
Created October 2, 2014 20:05
Show Gist options
  • Save remi/22e3b7489315c65d543b to your computer and use it in GitHub Desktop.
Save remi/22e3b7489315c65d543b to your computer and use it in GitHub Desktop.
Remove the useless and harmful ActiveRecord::SchemaDumper vertical alignment
# Remove the useless and harmful ActiveRecord::SchemaDumper vertical alignment
module ActiveRecord
class SchemaDumper
def table_with_sane_alignment(table, main_stream)
# Call the original method to populate our custom stream
stream = StringIO.new
table_without_sane_alignment(table, stream)
# Rewind the stream and remove useless whitespace
content = stream.tap(&:rewind).read.gsub(/(?<!^)(?<!\s)[ ]{2,}/, ' ')
main_stream.print(content)
# Rails expects the `#table` method to return the main stream
main_stream
end
alias_method_chain :table, :sane_alignment
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment