mongoid/mongoid — Issue #1440: undefined method 'first' for embedded with belongs_to self
Author: Tuxie
Created: 2011-11-20 00:24:32+00:00
State: open

Is this a bug or am I doing it wrong?

```ruby
class Foo
include Mongoid::Document
embeds_many :bars
end

class Bar
include Mongoid::Document
embedded_in :foo
belongs_to :other, class_name: 'Foo'
end

foo1, foo2 = Foo.create, Foo.create
foo1.bars.create(other: foo2)
```
.../gems/activemodel-3.1.2/lib/active_model/attribute_methods.rb:385:in 'method_missing': undefined method 'first' for #<Bar:0x007fdedea16e08> (NoMethodError)
from .../gems/mongoid-2.3.3/lib/mongoid/attributes.rb:184:in 'method_missing'
from .../gems/mongoid-2.3.3/lib/mongoid/relations/embedded/many.rb:263:in 'block (2 levels) in substitute'
from .../gems/mongoid-2.3.3/lib/mongoid/relations/embedded/atomic.rb:61:in 'call'
...