Guest User

Untitled

a guest
Jan 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. require 'bundler'
  2. Bundler.setup
  3.  
  4. require 'active_record'
  5.  
  6. def load_models
  7. puts "Loading models"
  8. require File.expand_path('../models', __FILE__)
  9. end
  10.  
  11. def connect_to_database
  12. puts "Creating and connecting to database"
  13. require File.expand_path('../database', __FILE__)
  14. end
  15.  
  16. def models_first?
  17. ARGV.first =~ /first/
  18. end
  19.  
  20. def msg
  21. "on ActiveRecord #{ActiveRecord::VERSION::STRING} with models loaded #{models_first? ? 'first' : 'second'}"
  22. end
  23.  
  24. begin
  25. puts "== Running #{msg}"
  26.  
  27. if models_first?
  28. load_models
  29. connect_to_database
  30. else
  31. connect_to_database
  32. load_models
  33. end
  34.  
  35. Person.create!(:name => 'Jo')
  36. puts "-- Successful #{msg}!"
  37. rescue => e
  38. puts "-- Failed #{msg}:"
  39. raise e
  40. end
Add Comment
Please, Sign In to add comment