Skip to content

Instantly share code, notes, and snippets.

@wmw
Created November 9, 2010 20:53
Show Gist options
  • Save wmw/669775 to your computer and use it in GitHub Desktop.
Save wmw/669775 to your computer and use it in GitHub Desktop.
require 'mm-paginate'
if ENV['MONGOHQ_URL']
MongoMapper.config = {RAILS_ENV => {'uri' => ENV['MONGOHQ_URL']}}
else
MongoMapper.config = {RAILS_ENV => {'uri' => 'mongodb://localhost:27071/shapado-development'}}
end
MongoMapperExt.init
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
MongoMapper.connection.connect_to_master if forked
end
end
Dir.glob("#{RAILS_ROOT}/app/models/**/*.rb") do |model_path|
File.basename(model_path, ".rb").classify.constantize
end
# HACK: do not create indexes on every request
module MongoMapper::Plugins::Indexes::ClassMethods
def ensure_index(*args)
end
end
Dir.glob("#{RAILS_ROOT}/app/javascripts/**/*.js") do |js_path|
code = File.read(js_path)
name = File.basename(js_path, ".js")
# HACK: looks like ruby driver doesn't support this
MongoMapper.database.eval("db.system.js.save({_id: '#{name}', value: #{code}})")
end
require 'support/versionable'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment