Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2087

raise_not_found_error: false is not working

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Here is my mongoid.yml:
      development:
      sessions:
      default:
      hosts:

      • localhost:27017
        database: dev_project_db
        options:
        identity_map_enabled: true
        include_root_in_json: false
        raise_not_found_error: false

      Console:
      irb(main):015:0> user = User.find_by(email: "jhon@doe.net")
      Mongoid::Errors::DocumentNotFound:
      Problem:
      Document not found for class Invoice with attributes {:email => "jhon@doe.net"}.
      Summary:
      When calling Invoice.find_by with a hash of attributes, all attributes provided must match a document in the database or this error will be raised.
      Resolution:
      Search for attributes that are in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error.
      from /Users/yacobusreinhart/local/tmp/Invoice/gems/mongoid/lib/mongoid/finders.rb:106:in `find_by'
      from (irb):15
      from /Users/yacobusreinhart/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
      from /Users/yacobusreinhart/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
      from /Users/yacobusreinhart/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
      from script/rails:6:in `require'
      from script/rails:6:in `<main>'

      irb(main):016:0> Mongoid.raise_not_found_error
      => true

      The problem occurs on find(object_id) and find(array_ids) too. any idea dude?

            Assignee:
            Unassigned Unassigned
            Reporter:
            jackbit jackbit
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: