You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Causes the Candy module to create a MongoDb connection to localhost, without actually using any Candy objects. Here's the stack, I'm using a git submodule that is a mirror of this repo:
➜ Istoria git:(version_two) ✗ bundle exec irb
irb(main):001:0> require 'candy'
Mongo::ConnectionFailure: failed to connect to any given host:port
from /home/paul/.bundle/ruby/1.9.1/gems/mongo-1.0/lib/mongo/connection.rb:435:in connect_to_master' from /home/paul/.bundle/ruby/1.9.1/gems/mongo-1.0/lib/mongo/connection.rb:112:ininitialize'
from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:50:in new' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:50:inconnection'
from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:72:in db' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:132:indb'
from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:166:in collection=' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/hash.rb:23:inclass:CandyHash'
from /home/paul/Projects/Istoria/vendor/candy/lib/candy/hash.rb:19:in <module:Candy>' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/hash.rb:3:in<top (required)>'
from /home/paul/Projects/Istoria/vendor/candy/lib/candy/collection.rb:2:in require' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/collection.rb:2:in<top (required)>'
from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:in require' from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:inblock in <top (required)>'
from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:in each' from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:in<top (required)>'
from (irb):1:in `require'
from (irb):1
The text was updated successfully, but these errors were encountered:
Good catch! You're completely right -- the intention was to have lazy everything, and not make any connections until the first data operation is performed. But I was sloppy and didn't test it on a machine that didn't have MongoDB running, so I didn't notice that an attempt to set a collection name was causing a cascade of references. I also think the "require everything" approach in the main candy.rb file was too greedy.
It's fixed now. Please try the latest version (gemmed and tagged as 0.2.6) and let me know if you still have any problems. Thanks very much for pointing this out.
Spinning up an irb prompt and running:
require 'candy'
Causes the Candy module to create a MongoDb connection to localhost, without actually using any Candy objects. Here's the stack, I'm using a git submodule that is a mirror of this repo:
➜ Istoria git:(version_two) ✗ bundle exec irb
irb(main):001:0> require 'candy'
Mongo::ConnectionFailure: failed to connect to any given host:port
from /home/paul/.bundle/ruby/1.9.1/gems/mongo-1.0/lib/mongo/connection.rb:435:in
connect_to_master' from /home/paul/.bundle/ruby/1.9.1/gems/mongo-1.0/lib/mongo/connection.rb:112:in
initialize'from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:50:in
new' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:50:in
connection'from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:72:in
db' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:132:in
db'from /home/paul/Projects/Istoria/vendor/candy/lib/candy/crunch.rb:166:in
collection=' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/hash.rb:23:in
class:CandyHash'from /home/paul/Projects/Istoria/vendor/candy/lib/candy/hash.rb:19:in
<module:Candy>' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/hash.rb:3:in
<top (required)>'from /home/paul/Projects/Istoria/vendor/candy/lib/candy/collection.rb:2:in
require' from /home/paul/Projects/Istoria/vendor/candy/lib/candy/collection.rb:2:in
<top (required)>'from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:in
require' from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:in
block in <top (required)>'from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:in
each' from /home/paul/Projects/Istoria/vendor/candy/lib/candy.rb:4:in
<top (required)>'from (irb):1:in `require'
from (irb):1
The text was updated successfully, but these errors were encountered: