Embedded association isn't saved when parent is saved

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Blocker - P1
    • None
    • Affects Version/s: 9.0.0, 9.0.1, 9.0.2, 9.0.3, 9.0.4, 9.0.5, 9.0.6
    • Component/s: Associations, Persistence
    • None
    • None
    • Ruby Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Embedded association is not saved when calling save on parent document!

      ```

      require 'rails_helper'
      
      RSpec.describe Client, type: :model do
        let(:client) { Fabricate(:client) }
      
        context 'when the embedded association is not set' do
          before do
            client.unset(:address)
      
            expect(client.reload.address).to be_nil
          end
      
          it 'saves address changes when assigned to a persisted client' do
            # Build and assign the address
            client.address = Address.new
            client.address.city = 'New York'
      
            client.save!
            # Verify the address was persisted correctly
            persisted_client = Client.find(client.id)
            expect(persisted_client.address).to be_present # present
            expect(persisted_client.address.city).to eq('New York') # fails!!!
          end
        end
      end
      

            Assignee:
            Dmitry Rybakov
            Reporter:
            Rodrigo R Aquino
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: