title: Change params value on model callback
body: <p>So I have 3 models <code>group</code>, <code>recipient</code> and <code>group_recipients</code>.</p>
  <pre><code>class Group &lt; ApplicationRecord
      has_many :group_recipients, dependent: :destroy
      has_many :recipients, through: :group_recipients
  end
  
  class GroupRecipient &lt; ApplicationRecord
      belongs_to :recipient, inverse_of: :group_recipients, autosave: true
      belongs_to :group
  end
  
  class Recipient &lt; ApplicationRecord
      has_many :group_recipients, inverse_of: :recipient, autosave: true, dependent: :destroy
      has_many :groups, through: :group_recipients
  end
  </code></pre>
  <p>Controller#update <code>recipients_controller.rb</code></p>
  <pre><code>def update
   @recipient = Recipient.with_deleted.find(params[:id])
   if @recipient.update(recipient_params)
    respond_to do |format|
      redirect_url = params[:commit] == 'Save and add another' ? new_recipient_path : edit_recipient_path(@recipient)
      format.html { redirect_to redirect_url, notice: 'Recipient was successfully updated.' }
      format.json { render json: {status: :success} }
    end
  else
    respond_to do |format|
      format.html { render :edit }
      format.json do
        render json: {
          status: :error,
          recipient: @recipient,
          errors: @recipient.errors
        }
      end
    end
  end
  end
  
   def recipient_params
     params.require(:recipient).permit(
     :email_address, :first_name, :last_name, :language_id,
     :phone, group_ids: [])
   end
  </code></pre>
  <p>On recipient <code>update</code>, <code>params[:group_ids]</code> is received. Here, on <code>before_update</code> callback I want to be able to change the <code>group_ids</code> value with some logic. I might have to add or remove data from <code>group_ids</code> array.</p>
  <p>The problem is activerecord updates all the groups according to <code>params[:group_ids]</code> even if I change it. It doesnot matter if I use it in before or after callback. Once I set the values in <code>self.group_ids</code>, it does make those changes but once the transaction completes, it again revert those changes.</p>