Skip to content
Browse files

move to mongo yaml

  • Loading branch information...
1 parent 42af21f commit e255537b8017fd1da788ba4d61e1bd4974bec6c4 @stefl committed Aug 10, 2012
Showing with 108 additions and 19 deletions.
  1. +26 −5 Readme.md
  2. +1 −14 config/database.rb
  3. +81 −0 config/mongoid.yml
View
31 Readme.md
@@ -8,15 +8,36 @@ Fork the project, then:
git clone git://github.com/stefl/bootbuckle.git
bundle install
-If you don't have MongoDB locally, and you're on OSX, then install Homebrew, followed by:
+If you don't have MongoDB and Memcache locally, and you're on OSX, then install Homebrew, followed by:
brew update
brew install mongodb
+ brew install memcached
+ memcached
-Edit config/database.rb and replace "bootbuckle" with something else at this line:
+Edit config/mongoid.yml and replace "bootbuckle_development" with something else at this line:
- Mongoid.database = connection.db("bootbuckle")
+ database: bootbuckle_development
-Then do a global find and replace for "Bootbuckle", replacing it with your preferred application name.
+Do a global find and replace for "Bootbuckle", replacing it with your preferred application name.
-Then
+Then [get a 64-character hex string](https://www.grc.com/passwords.htm) and replace "change_this" at this line of config/apps.rb:
+
+ set :session_secret, 'change_this'
+
+Edit the application settings in app/app.rb:
+
+ set :google_analytics, "XXXXXXXX"
+ set :typekit, "ABC123"
+ set :title, "My new app"
+ set :base_host, "mynewapp.com"
+ set :description, "A new shiny thing, how exciting!"
+
+To deploy to Heroku on the new Cedar stack:
+
+ heroku create my_app_name --stack cedar
+ git push heroku
+
+To run locally:
+
+ foreman start -f Procfile.dev
View
15 config/database.rb
@@ -1,16 +1,3 @@
Mongoid.skip_version_check = true
-# Connection.new takes host, port
-port = Mongo::Connection::DEFAULT_PORT
-
-case Padrino.env
- when :development then
- connection = Mongo::Connection.new("localhost", port, {:pool_timeout => 60, :pool_size => 5, :timeout => 10})
- Mongoid.database = connection.db("bootbuckle")
- when :production then
- uri = URI.parse(ENV['MONGOLAB_URI'])
- connection = Mongo::Connection.from_uri(ENV['MONGOLAB_URI'], {:pool_timeout => 60, :pool_size => 5, :timeout => 10})
- Mongoid.database = connection.db(uri.path.gsub(/^\//, ''))
-end
-
-MONGO_CONNECTION = connection
+Mongoid.load!(File.dirname(__FILE__) + "/mongoid.yml")
View
81 config/mongoid.yml
@@ -0,0 +1,81 @@
+development: &defaults
+ # Configure available database sessions. (required)
+ sessions:
+ # Defines the default session. (required)
+ default: &default_session
+ # Defines the name of the default database that Mongoid can connect to.
+ # (required).
+ database: bootbuckle_development
+ # Provides the hosts the default session can connect to. Must be an array
+ # of host:port pairs. (required)
+ hosts:
+ - localhost:27017
+ options:
+ # Change whether the session persists in safe mode by default.
+ # (default: false)
+ # safe: false
+
+ # Change the default consistency model to :eventual or :strong.
+ # :eventual will send reads to secondaries, :strong sends everything
+ # to master. (default: :eventual)
+ # consistency: :strong
+ # Configure Mongoid specific options. (optional)
+ options:
+ # Configuration for whether or not to allow access to fields that do
+ # not have a field definition on the model. (default: true)
+ # allow_dynamic_fields: true
+
+ # Enable the identity map, needed for eager loading. (default: false)
+ # identity_map_enabled: false
+
+ # Includes the root model name in json serialization. (default: false)
+ # include_root_in_json: false
+
+ # Include the _type field in serializaion. (default: false)
+ # include_type_for_serialization: false
+
+ # Preload all models in development, needed when models use
+ # inheritance. (default: false)
+ preload_models: true
+
+ # Protect id and type from mass assignment. (default: true)
+ # protect_sensitive_fields: true
+
+ # Raise an error when performing a #find and the document is not found.
+ # (default: true)
+ raise_not_found_error: false
+
+ # Raise an error when defining a scope with the same name as an
+ # existing method. (default: false)
+ # scope_overwrite_exception: false
+
+ # Skip the database version check, used when connecting to a db without
+ # admin access. (default: false)
+ # skip_version_check: false
+
+ # User Active Support's time zone in conversions. (default: true)
+ # use_activesupport_time_zone: true
+
+ # Ensure all times are UTC in the app side. (default: false)
+ # use_utc: false
+
+test:
+ <<: *defaults
+ sessions:
+ default:
+ <<: *default_session
+ database: delight_test
+
+<% if url = (ENV['MONGOHQ_URL'] || ENV['MONGOLAB_URL']) %>
+ <% uri = URI.parse(url) %>
+production:
+ <<: *defaults
+ sessions:
+ default:
+ <<: *default_session
+ database: <%= uri.path.sub('/','') %>
+ username: <%= uri.user %>
+ password: <%= uri.password %>
+ hosts:
+ - <%= uri.host %>:<%= uri.port %>
+<% end %>

0 comments on commit e255537

Please sign in to comment.
Something went wrong with that request. Please try again.