title: How to avoid Rails caching from causing child objects to appear to not exist
body: <p>I'm working on an order application, which is accepting orders from the CC Processing vendor, and passing them off to a fulfillment application.</p>
  <pre><code>class Order &lt; ApplicationRecord
    has_many :items, class_name: 'Product'
    def payload
      @builder = Nokogiri::XML::Builder.new do |xml|
        ...
        self.items.each do |o|
          ...
        end
      end
      @builder.to_xml
    end
    ...
  end
  </code></pre>
  <p>When an order comes in, it creates all of the needed records, and then tries to pass of the payload to the fulfillment application</p>
  <pre><code>def generate_order
    ActiveRecord::Base.transaction do
      # create order
      ...
      External.send_order(self) # Web Call to Customer Support system &lt;= this is were caching is happening
      Product.create!(...) #create the actual product items
      p &quot;Payload #{self.payload}&quot;
    rescue StandardError =&gt; e
      ...
    end
  end
  </code></pre>
  <p>Because we are passing the order itself to Customer Support system, before we've actually processed the items, Rails is caching the order without any items.  So when we try to view the payload, the items aren't present.</p>
  <p>I can move the callout to the customer support system until after we process the items and work around it, but..</p>
  <p>How can we ensure that we are working from a current/non-cached version of the order?</p>