Class: Dbmapper::DatabaseMapper
- Inherits:
-
Object
- Object
- Dbmapper::DatabaseMapper
- Defined in:
- lib/dbmapper.rb
Instance Method Summary collapse
- #all_columns ⇒ Object
- #all_models ⇒ Object
- #all_models_with_association ⇒ Object
- #initlialize ⇒ Object
Instance Method Details
#all_columns ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dbmapper.rb', line 21 def all_columns #open file text_file = File.open("mapped_databse.txt", 'w') ActiveRecord::Base.descendants.each do |model| text_file.write(model) text_file.write("\n\n") model.column_names.each do |column| text_file.write(column) text_file.write("\n") end end puts "All your columns have been written to mapped_databse.txt" text_file.close end |
#all_models ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dbmapper.rb', line 10 def all_models #open file text_file = File.open("mapped_databse.txt", 'w') ActiveRecord::Base.descendants.each do |model| text_file.write(model) text_file.write("\n") end puts "All your models have been written to mapped_databse.txt" text_file.close end |
#all_models_with_association ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dbmapper.rb', line 36 def all_models_with_association #open file text_file = File.open("mapped_databse.txt", 'w') association_string = "-->" ActiveRecord::Base.descendants.each do |model| text_file.write(model) text_file.write("\n") model.reflect_on_all_associations.map(&:name).each do |assocations| association_string = association_string + " #{assocations}," end text_file.write(association_string) text_file.write("\n\n") association_string = "-->" end puts "all models with their assocations have been written to mapped_databse.txt" text_file.close end |
#initlialize ⇒ Object
6 7 8 |
# File 'lib/dbmapper.rb', line 6 def initlialize Rails.application.eager_load! end |