diff options
Diffstat (limited to 'core/lib')
-rw-r--r-- | core/lib/extensions/couchrest.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb index 57bb837..176184f 100644 --- a/core/lib/extensions/couchrest.rb +++ b/core/lib/extensions/couchrest.rb @@ -23,11 +23,33 @@ module CouchRest end end + module Errors + class ConnectionFailed < CouchRestModelError; end + end + + module Connection + + module ClassMethods + + def use_database(db) + @database = prepare_database(db) + rescue RestClient::Unauthorized, + Errno::EHOSTUNREACH, + Errno::ECONNREFUSED => e + raise CouchRest::Model::Errors::ConnectionFailed.new(e.to_s) + end + end + + end + class Migrate def self.load_all_models_with_engines self.load_all_models_without_engines return unless defined?(Rails) - Dir[Rails.root + '**/models/**/*.rb'].each do |path| + Dir[Rails.root + 'app/models/**/*.rb'].each do |path| + require path + end + Dir[Rails.root + '*/app/models/**/*.rb'].each do |path| require path end end |