Changed how database instance and activerecord instance is created