Created
April 27, 2016 14:52
-
-
Save lucivaldo/98f1948de5b344815cf15ca41433cba3 to your computer and use it in GitHub Desktop.
Rake task for display all models of the application
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
namespace :my_app do | |
desc "Display all models" | |
task models: :environment do |t| | |
puts 'Tabelas existentes:', "" | |
ActiveRecord::Base.connection.tables.delete_if do |table| | |
table.include? 'schema' | |
end.each do |table| | |
puts "<<<< #{table} >>>>" | |
ActiveRecord::Base.connection.columns(table).each do |column| | |
puts " #{column.name}, #{column.type}" | |
end | |
puts "" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment