Permalink
Browse files

Added mongo_mapper:config generator

  • Loading branch information...
bkeepers committed Sep 12, 2010
1 parent 1fe01b6 commit eca638524b67dc6521410f85aad20257be956065
@@ -0,0 +1,24 @@
# encoding: utf-8
module MongoMapper
module Generators
class ConfigGenerator < Rails::Generators::Base
desc "creates the MongoMapper configuration at config/mongo.yml"
argument :database_name, :type => :string, :optional => true
def self.source_root
@source_root ||= File.expand_path("../templates", __FILE__)
end
def app_name
Rails::Application.subclasses.first.parent.to_s.underscore
end
def create_config_file
template 'mongo.yml', File.join('config', "mongo.yml")
end
end
end
end
@@ -0,0 +1,18 @@
defaults: &defaults
host: 127.0.0.1
port: 27017
development:
<<: *defaults
database: <%= database_name || app_name %>_development
test:
<<: *defaults
database: <%= database_name || app_name %>_test
# set these environment variables on your prod server
production:
<<: *defaults
database: <%= database_name || app_name %>
username: <%%= ENV['MONGO_USERNAME'] %>
password: <%%= ENV['MONGO_PASSWORD'] %>

0 comments on commit eca6385

Please sign in to comment.