Permalink
Commits on Jul 31, 2010
  1. And we have explicit $inc support:

    - model_instance.inc(field, value, opts) will now allow a $inc
      against the database.
    - opts gets passed through to driver... (ie safe mode, etc)
    - Fields get automagically updated in the model when this is called.
    durran committed Jul 31, 2010
Commits on Jul 30, 2010
  1. Adding first part direct support

    durran committed Jul 30, 2010
  2. Moving dependent check into proxy

    durran committed Jul 30, 2010
  3. Providing better user feedback on association definitions:

    - Converted all error messages to i18n
    - EmbedsOne and EmbedsMany now raise an error if trying to
      define a dependent option.
    - ReferencedIn now errors when trying to define a dependent
      option.
    - Moved the inverse_of error on EmbeddedIn into the association
      class.
    durran committed Jul 30, 2010
  4. Moved EmbeddedIn options check into association itself

    Durran Jordan and Robert Pitts committed with durran Jul 29, 2010
  5. No need to bundle exec rake spec anymore, added bundler to Rakefile

    Durran Jordan and Robert Pitts committed with durran Jul 29, 2010
  6. Cleaning up whitespace

    durran committed Jul 29, 2010
  7. Updating version to beta 15

    Durran Jordan and Les Hill and Paul Elliott and Tim Pope committed with durran Jul 29, 2010
  8. Add rake task db:mongoid:objectid_convert

    This task will go through all your Mongoid collections, and convert string objectids to ObjectIDs. Converted from the code on Kyle Banker's gist here: http://gist.github.com/489098
    jacquescrocker committed Jul 29, 2010
  9. Fixing small doc typo

    jacquescrocker committed Jul 30, 2010
Commits on Jul 29, 2010
  1. Revert "convert database rake task"

    This reverts commit 3e7782c.
    jacquescrocker committed Jul 29, 2010
  2. Allow nil proxies to respond properly to nil?

    This fixes the issue where:
    
      @model.account = nil
      @model.account #=> nil
        @model.account.nil? #=> false
    jacquescrocker committed Jul 29, 2010
  3. Changing index rake task not to use the module descendents method

    Durran Jordan and Les Hill and Paul Elliott and Tim Pope committed with durran Jul 29, 2010
  4. Fixing the memory faucet:

    - Notes for people submitting patches in the future: Please do
      not use class variables... Very, very bad.
    Durran Jordan and Les Hill and Paul Elliott and Tim Pope committed with durran Jul 29, 2010
  5. Minor doc fix

    jacquescrocker committed Jul 29, 2010
  6. Allow referenced_in association to be nil

    Until a few days ago, Mongoid supported objects which were optionally
    referenced_in a parent object's references_many, but which could also
    stand on their own.  Recently, this has stopped working, and started
    generating errors about an object with an id of 4.
    
        Failure/Error: @account.creator.should be_nil
        Document not found for class User with id(s) 4
        # ./spec/../lib/mongoid/contexts/ids.rb:19:in `id_criteria'
        # ./spec/../lib/mongoid/criteria.rb:31:in `__send__'
        # ./spec/../lib/mongoid/criteria.rb:31:in `id_criteria'
        # ./spec/../lib/mongoid/criteria.rb:189:in `translate'
        # ./spec/../lib/mongoid/finders.rb:68:in `find'
        # ./spec/../lib/mongoid/associations/referenced_in.rb:21:in `initialize'
        # ./spec/../lib/mongoid/associations.rb:280:in `new'
        # ./spec/../lib/mongoid/associations.rb:280:in `creator'
        # ./spec/../lib/mongoid/memoization.rb:11:in `memoized'
        # ./spec/../lib/mongoid/associations.rb:279:in `creator'
        # ./spec/integration/mongoid/associations_spec.rb:224
    
    These errors are caused by the following two lines of code in
    Association's update_foreign_keys method:
    
        target = send(name)
        send("#{foreign_key}=", target ? target.id : nil)
    
    This code is manipulating proxy objects, which don't do the expected
    thing when evaluated in a conditional statement:
    
        class ExampleProxy < Mongoid::Associations::Proxy
          def initialize(target)
            @target = target
          end
        end
    
        proxy = ExampleProxy.new(nil)
        proxy.nil? => false
        (proxy ? true : false) => true
    
    According to folks on the ruby IRC channel, there's no way to make a
    proxy object reliably behave like nil when used in a conditional
    expression.
    
    If we make the use of proxies explicit in this code, then all the unit
    tests pass and we stop accidentally storing 4 (the id of nil!) in the
    database.
    
        proxy = send(name)
        send("#{foreign_key}=", proxy && proxy.target ? proxy.id : nil)
    
    There's an analogous use of proxy.target in the associate method:
    
        proxy.target ? proxy : nil
    
    ...so this behavior is consistent with other code in Mongoid.
    emk committed with jacquescrocker Jul 29, 2010
  7. Fixing broken specs.

    - ObjectID#as_json should always override.
    - Criteria integration spec got in merge trouble, reverted
      to correct version.
    durran committed Jul 29, 2010
  8. Finishing basic dependent => destroy|delete options on relational

    associations. Fixes #135.
    
    Current available options:
    
    - references_many :name, :dependent => :destroy
    - references_one :name, :dependent => :delete
    
    We can expand this later if need be if we need more
    functionality around this.
    durran committed Jul 29, 2010