Skip to content

Instantly share code, notes, and snippets.

bhbryant

Block or report user

Report or block bhbryant

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bhbryant
bhbryant / retry.rb
Created Sep 21, 2011
auto-failover ReplicaSet config for MongoMapper, by way of ruby driver
View retry.rb
replica_sets = mm_env['replica_sets'] # node1:port&node2:port
rs_list = replica_sets.split("&").map {|rs| host,port = rs.split(":"); [host,port.to_i] }
MongoMapper.connection = Mongo::RetryReplicaSetConnection.new(*(rs_list << {:read_secondary => true, :auto_refresh => true }))
MongoMapper.database = mm_env['database']
MongoMapper.database.authenticate(mm_env['username'], mm_env['password'])
View gist:510365
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/source.rb:552:in `load_spec_files': git://github.com/bhbryant/aasm.git (at master) is not checked out. Please run `bundle install` (Bundler::PathError)
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/source.rb:371:in `local_specs'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/source.rb:534:in `specs'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/lazy_specification.rb:48:in `__materialize__'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/spec_set.rb:83:in `materialize'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/spec_set.rb:81:in `map!'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/spec_set.rb:81:in `materialize'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.2/lib/bundler/definition.rb:93:in `specs'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0.r
View mongo_paperclip.rb
module Paperclip
class << self
def logger #:nodoc:
MongoMapper.logger
end
end
module ClassMethods
def has_attached_file name, options = {}
include InstanceMethods
View nested_attributes.rb
# This is an incomplete implementation.
module MongoMapper
module NestedAttributes
def self.included(base)
base.extend(ClassMethods)
base.send :include, InstanceMethods
end
module ClassMethods
def accepts_nested_attributes_for(*attr_names)
You can’t perform that action at this time.