couchrest_model/lib/couchrest/railtie.rb

25 lines
700 B
Ruby
Raw Normal View History

2010-08-24 01:27:17 +02:00
require "rails"
require "active_model/railtie"
2011-04-30 00:34:12 +02:00
module CouchRest
class ModelRailtie < Rails::Railtie
2011-06-12 20:19:59 +02:00
def self.generator
config.respond_to?(:app_generators) ? :app_generators : :generators
end
2011-06-12 20:19:59 +02:00
config.send(generator).orm :couchrest_model
config.send(generator).test_framework :test_unit, :fixture => false
2011-04-30 00:34:12 +02:00
initializer "couchrest_model.configure_default_connection" do
CouchRest::Model::Base.configure do |conf|
conf.environment = Rails.env
conf.connection_config_file = File.join(Rails.root, 'config', 'couchdb.yml')
conf.connection[:prefix] =
Rails.application.class.to_s.underscore.gsub(/\/.*/, '')
end
end
2010-08-24 01:27:17 +02:00
end
2011-04-30 00:34:12 +02:00
2010-08-24 01:27:17 +02:00
end
2011-04-30 00:34:12 +02:00