title: rails 4 deep_clone different in development/staging and production
body: <p>I am running a rails 4 app. Everything works fine so far, but now a strange error happened with deep_clone from the gem deep_clonable. I made a controller method to duplicate an entry (Interaction model/controller).</p>
  <p>interactions_controller.rb:</p>
  <pre><code>def duplicate
    @interaction = Interaction.find(params[:id]).deep_clone include: [ :interaction_solvents, :interaction_additives], skip_missing_associations: true
    @interaction.user = current_user
  
  respond_to do |format|
      if @interaction.save
        format.html { redirect_to @interaction, notice: 'Item was successfully cloned.' }
      else
        format.html {  redirect_to Interaction.find(params[:id]), notice: 'ERROR: Item can\'t be cloned.'}
      end
    end
  end
  </code></pre>
  <p>I develop with docker and use capistrano to deploy the code to a staging and production server. The staging and production servers are identical and I deploy in ENV=production. For deployment I use two files which only differ in the IP and the lack of a deployment backup for staging.</p>
  <p>config/deploy/production.rb:</p>
  <pre><code>user = 'prod'
  
          before 'deploy:migrate', 'deploy:backup'
      
      server 'XXX.XX.146.242', user: user, roles: %w{app web db}
      puts %w(publickey)
      set :ssh_options, {
        forward_agent: true,
        auth_methods: %w(publickey)
      }
      #set :pty, false
      
      set :linked_files, fetch(:linked_files, []).push(
        '.ruby-version',
        '.ruby-gemset'
      )...
  </code></pre>
  <p>config/deploy/staging.rb:</p>
  <pre><code>    user = 'prod'
      
      #before 'deploy:migrate', 'deploy:backup'
      
      server 'XXX.XX.146.243', user: user, roles: %w{app web db}
      puts %w(publickey)
      set :ssh_options, {
        forward_agent: true,
        auth_methods: %w(publickey)
      }
      #set :pty, false
      
      set :linked_files, fetch(:linked_files, []).push(
        '.ruby-version',
        '.ruby-gemset'
      )
      
      #set :tmp_dir, &quot;/home/#{user}/tmp&quot;
      set :user, user
  </code></pre>
  <p>Now it comes. Everything with calling duplicate works absolutely fine in development and staging. In production the duplication is doubled and 2 new copies are generated. I updated both servers and checked the versions. Here are some specs:</p>
  <ul>
  <li>Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-36-generic x86_64)</li>
  <li>nginx version: nginx/1.14.0 (Ubuntu)</li>
  <li>Rails 4.2.10</li>
  <li>postgres (PostgreSQL) 10.12 (Ubuntu 10.12-0ubuntu0.18.04.1)</li>
  </ul>
  <p>Parts of the Production logs:</p>
  <pre><code>I, [2020-06-25T15:02:10.184115 #32495]  INFO -- : Started GET &quot;/interactions/7336/duplicate&quot; for 127.0.0.1 at 2020-06-25 15:02:10 +0200
  I, [2020-06-25T15:02:10.186316 #32495]  INFO -- : Processing by InteractionsController#duplicate as HTML
  I, [2020-06-25T15:02:10.186455 #32495]  INFO -- :   Parameters: {&quot;id&quot;=&gt;&quot;7336&quot;}
  ...
  I, [2020-06-25T15:02:11.514185 #32495]  INFO -- : Redirected to http://suprabank.org/interactions/7338
  I, [2020-06-25T15:02:11.514595 #32495]  INFO -- : Completed 302 Found in 1328ms (ActiveRecord: 32.0ms)
  I, [2020-06-25T15:02:11.590073 #32495]  INFO -- : Started GET &quot;/interactions/7336/duplicate&quot; for 127.0.0.1 at 2020-06-25 15:02:11 +0200
  I, [2020-06-25T15:02:11.592145 #32495]  INFO -- : Processing by InteractionsController#duplicate as HTML
  I, [2020-06-25T15:02:11.592555 #32495]  INFO -- :   Parameters: {&quot;id&quot;=&gt;&quot;7336&quot;}
  ...
  I, [2020-06-25T15:02:12.705493 #32495]  INFO -- : Redirected to http://suprabank.org/interactions/7339
  I, [2020-06-25T15:02:12.705750 #32495]  INFO -- : Completed 302 Found in 1113ms (ActiveRecord: 23.1ms)
  I, [2020-06-25T15:02:12.789812 #32495]  INFO -- : Started GET &quot;/interactions/7339&quot; for 127.0.0.1 at 2020-06-25 15:02:12 +0200
  I, [2020-06-25T15:02:12.791400 #32495]  INFO -- : Processing by InteractionsController#show as HTML
  I, [2020-06-25T15:02:12.791546 #32495]  INFO -- :   Parameters: {&quot;id&quot;=&gt;&quot;7339&quot;}
  </code></pre>
  <p>From the logs it seems its the first duplication of entry 7336 works fine but then the route goes the wrong way and another GET request on 7336/duplicate is called. This is not supposed to happen, and does not happen in staging. After that little detour server correctly loads the show action of the (secondly) duplicated entry 7339.</p>
  <p>I updated both servers and restarted nginx but all the time the mismatch in actions between identical staging and production server?</p>
  <p>Any idea what is the error?</p>
  <p>Thanks in advance,
  Stephan</p>