-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
The 1-1 Relationship docs seems to suggest that the following relationship would work:
band = Band.new
band.create_studio(name: 'Le Studio')
expect( band.studio ).to eq Studio.first
expect( Studio.first.band ).to eq band
It does not. Studio.first.band is nil. The band_id "foreign key" is, however, set correctly.
The relationship does work as expected by reversing the has_one/belongs_to relationship:
Unable to find source-code formatter for language: `. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
class Band include Mongoid::Document belongs_to :studio end class Studio include Mongoid::Document field :name, type: String has_one :band end
`
I wonder if the behavior is intended or if the docs could be updated...?