-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
I have these models:
class User
include Mongoid::Document
has_one_related :account, :foreign_key => :creator_id
end
class Account
include Mongoid::Document
belongs_to_related :creator, :class_name => "User", :foreign_key => :creator_id, :inverse_of => :account
end
When I try to do @user.account.build, it tries to @account.user = @user, when it should call @account.creator = @user instead.
The culprit is in line 14-16 of mongoid/associations/has_one_related.rb
@target = @klass.instantiate(attributes)
name = @parent.class.to_s.underscore
@target.send("#
=", @parent)
It doesn't seem to respect the name of the belongs_to_related association.