Skip to content

Instantly share code, notes, and snippets.

View arthurnn's full-sized avatar
🟢
CI is passing

Arthur Nogueira Neves arthurnn

🟢
CI is passing
View GitHub Profile
@arthurnn
arthurnn / bug.rb
Last active December 25, 2015 01:09
class Face
belongs_to :man
end
class Man
has_one :face
before_save do
# this will autosave the parent.
create_face!
diff --git a/lib/moped/connection/queue.rb b/lib/moped/connection/queue.rb
index fe3a336..82fc666 100644
--- a/lib/moped/connection/queue.rb
+++ b/lib/moped/connection/queue.rb
@@ -84,7 +84,7 @@ module Moped
loop do
return queue.pop unless queue.empty?
wait = deadline - Time.now
- raise Timeout::Error, "Waited for item but none was pushed." if wait <= 0
+ raise Timeout::Error, "Waited for item but none was pushed. [thread list: #{Thread.list}, current: #{Thread.current.object_id}]" if wait <= 0

Counter Cache

###Example: Model definition:

  class Person
    include Mongoid::Document
    has_many :kittens
    field :kittens_counter, type: Integer, default: 0
 end
class PostSerializer
embed :ids
end
class CatSerializer
embed :ids, include: true
end
class MongoidConnectionMiddleware
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
ensure
clean_connection
end
class Hotel
include Mongoid::Document
field :name, localize: true
field :coordinates
end
2_000.times do |i|
Hotel.create!(name: "hotel #{i}", coordinates: i*2)
end
Arthurs-MacBook-Pro:~ arthurnn$ mongo mongodb://heroku_app19278391:[email protected]:53858/heroku_app19278391
MongoDB shell version: 2.4.7
connecting to: mongodb://heroku_app19278391:[email protected]:53858/heroku_app19278391
Thu Nov 7 19:00:39.329 Assertion failure _setName.size() src/mongo/client/dbclientinterface.h 211
0x10a63c530 0x10a615687 0x10a58e376 0x10a578852 0x10a60ac01 0x10a5fba1f 0x10a6fa638 0x1cfdb5b06362
0 mongo 0x000000010a63c530 _ZN5mongo15printStackTraceERSo + 64
1 mongo 0x000000010a615687 _ZN5mongo12verifyFailedEPKcS1_j + 295
2 mongo 0x000000010a58e376 _ZN5mongo16ConnectionStringC2ENS0_14ConnectionTypeERKSsS3_ + 390
3 mongo 0x000000010a578852 _ZN5mongo16ConnectionString5parseERKSsRSs + 322
4 mongo 0x000000010a60ac01 _ZN5mongo17mongoConsExternalEPNS_7V8ScopeERKN2v89
require 'moped'
logg = Logger.new $stdout
logg.level = 0
Moped.logger = logg
s = Moped::Session.new(['ds053858.mongolab.com:53858'], {database: 'heroku_app19278391', pool_size: 1})
s.login('heroku_app19278391', '79n011fsj88dh88d8q8g2k5k4j')
p s.command(ismaster: 1)
require 'mongoid'
require 'mongoid/support/query_counter'
CONFIG = {
sessions: {
default: {
database: "mongoid_test",
hosts: [ "localhost:27017" ]
}
}
require 'mongoid'
require 'mongoid/support/query_counter'
CONFIG = {
sessions: {
default: {
database: "mongoid_test",
hosts: [ "localhost:27017" ]
}
}