Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'bundler'
- Bundler.setup
- require 'active_record'
- def load_models
- puts "Loading models"
- require File.expand_path('../models', __FILE__)
- end
- def connect_to_database
- puts "Creating and connecting to database"
- require File.expand_path('../database', __FILE__)
- end
- def models_first?
- ARGV.first =~ /first/
- end
- def msg
- "on ActiveRecord #{ActiveRecord::VERSION::STRING} with models loaded #{models_first? ? 'first' : 'second'}"
- end
- begin
- puts "== Running #{msg}"
- if models_first?
- load_models
- connect_to_database
- else
- connect_to_database
- load_models
- end
- Person.create!(:name => 'Jo')
- puts "-- Successful #{msg}!"
- rescue => e
- puts "-- Failed #{msg}:"
- raise e
- end
Add Comment
Please, Sign In to add comment