Skip to content

Instantly share code, notes, and snippets.

@lucivaldo
Created April 27, 2016 14:52
Show Gist options
  • Save lucivaldo/98f1948de5b344815cf15ca41433cba3 to your computer and use it in GitHub Desktop.
Save lucivaldo/98f1948de5b344815cf15ca41433cba3 to your computer and use it in GitHub Desktop.
Rake task for display all models of the application
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