-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Associations
When setting child attribute via nested_attribute, we cannot access its parent. I've created a demo app to demonstrate the issue.
class Image include Mongoid::Document embedded_in :page def bam= value puts 'calling bam=' byebug puts "page: #{page}" # This is nil. Incorrect. end end class Page include Mongoid::Document embeds_many :images, cascade_callbacks: true accepts_nested_attributes_for :images end attributes = { 'images_attributes' => { '0' => { 'bam' => 'bam' } } } page = Page.new page.attributes = attributes puts 'after setting attributes' puts page.images.first.page
- is related to
-
MONGOID-2586 cannot access parent object in the after_find function
- Closed