Last active
December 20, 2015 03:29
-
-
Save tka/6064129 to your computer and use it in GitHub Desktop.
rails dump db schema to html table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.connection.tables.map{|table| | |
x=ActiveRecord::Base.connection.select('show full columns from '+table); | |
x.columns.slice!(7); | |
x.rows.each{|r| r.slice!(7)}; | |
"<h1>#{table}</h1>"+'<table class="table table-bordered table-striped"><tr><th>'+x.columns.join('</th><th>')+"</th><th></th></tr>\n" + x.rows.map{|y| '<tr><td>'+y.join('</td><td>')+"</td><td></td></tr>\n"}.join('')+"</table>\n"}.join('</hr>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment