mongoid/mongoid — Issue #1704: nil-error in relations/referenced/many.rb:546 (master)
Author: fwoeck
Created: 2012-02-11 12:25:50+00:00
State: open

Hi, not quite sure why yet, but I'm sometimes experiencing nill errors here:

relations/referenced/many.rb:546:in `criteria': undefined method `inverse_of_field' for nil:NilClass

in master.

Asking for inverse_metadata first solves it for me:

````ruby
inverse_metadata = metadata.inverse_metadata(metadata.klass)
if inverse_metadata && inverse_metadata.inverse_of_field
crit = crit.any_in(inverse_metadata.inverse_of_field => [metadata.name, nil])
end
````

Regards,
Frank