Closed robj closed 8 years ago
If defining own ids (ie. 'columns :id => :string' ), a belongs_to objects backreference will return a finder, not the object it belongs to.
ie.
MessageThread has_many :posts Post belongs_to :message_thread
(main)> Post.last.message_thread_id => 5277760 (main)> Post.last.message_thread => MessageThread#5277760:0x135b4c00
(main)> Post.last.message_thread_id => "5277760fe1054e3fa2000001" (main)> Post.last.message_thread => #<MotionModel::ArrayFinderQuery:0xdda29e0 @field_name=:"5277760fe1054e3fa2000001" @collection=[MessageThread#529ff44... ... ...
I created a branch issue98. If you could create a repro failing spec that would be great. A fix would be even better :)
issue98
Fixed by #143
If defining own ids (ie. 'columns :id => :string' ), a belongs_to objects backreference will return a finder, not the object it belongs to.
ie.
MessageThread has_many :posts Post belongs_to :message_thread
no custom ids
(main)> Post.last.message_thread_id => 5277760 (main)> Post.last.message_thread => MessageThread#5277760:0x135b4c00
custom ids
(main)> Post.last.message_thread_id => "5277760fe1054e3fa2000001" (main)> Post.last.message_thread => #<MotionModel::ArrayFinderQuery:0xdda29e0 @field_name=:"5277760fe1054e3fa2000001" @collection=[MessageThread#529ff44... ... ...