title: Back Button Skipping Page in Ruby on Rails application
body: <p>I have found many generic posts suggesting this has to do with redirects.  I believe this may be due to how I have a form set up. </p>
  
  <p>On the <code>plans.html.erb</code> page I have a form with four submits, each going to the same place with different params: </p>
  
  <pre><code>&lt;%= form_with url: :affiliate_select_plan, class: "mx-auto" do |f|  %&gt;
  
      &lt;!-- Paid Plans --&gt;
      &lt;% @plans.each_with_index do |plan, i| %&gt;
          &lt;%= f.button 'Select Plan', value: plan[:name], type: 'submit' %&gt; 
  
      &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I have the <code>affiliate_select_plan_path</code> setup in my <code>routes.rb</code>: </p>
  
  <pre><code>devise_scope :affiliate do
    post 'affiliate/select_plan', :to =&gt; 'affiliates/registrations#select_plan'
  end
  </code></pre>
  
  <p>The form successfully hits the <code>select_plan</code> method in the controller, which redirects it to the <code>new_affiliate_registration_path</code>, passing the needed params. </p>
  
  <pre><code>def select_plan
      redirect_to new_affiliate_registration_path(plan: plan_params[:button])
  end 
  </code></pre>
  
  <p>The <code>new</code> method in the controller is called, directing the user to the sign up page: </p>
  
  <pre><code># GET /resource/sign_up
  def new
      @plan = AffiliatePlan.find_by(nickname: params.permit(:plan)[:plan].downcase)
      super
  end
  </code></pre>
  
  <p>From this page, if the back button on the browser is selected, it will bring the user back to the page they were at before being at <code>plans.html.erb</code>.  </p>
  
  <p>Could this be related to the <code>redirect_to</code>? </p>
  
  <hr>
  
  <h2>EDIT:</h2>
  
  <p>Here are the logs: </p>
  
  <pre><code>Started GET "/" for 127.0.0.1 at 2020-02-25 19:06:02 -0500
  Processing by Affiliates::RegistrationsController#plans as HTML
    Rendering affiliates/registrations/plans.html.erb within layouts/application
    Rendered affiliates/registrations/plans.html.erb within layouts/application (5.2ms)
    Rendered layouts/_google_analytics.html.erb (0.5ms)
  [Webpacker] Everything's up-to-date. Nothing to do
    Rendered layouts/_header.html.erb (1.2ms)
    Rendered layouts/_footer.html.erb (0.7ms)
  Completed 200 OK in 195ms (Views: 194.2ms | ActiveRecord: 0.0ms)
  
  
  Started POST "/partner/select_plan" for 127.0.0.1 at 2020-02-25 19:06:13 -0500
  Processing by Affiliates::RegistrationsController#select_plan as JS
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"Ck8HGRryriXleQrUjCSKjTrIRLIw273EdSu4WZnFn3kAL1mMmk7jqR1tZgnPniHsMzHFMl81vPBRuvA0/W4uSw==", "button"=&gt;"Local"}
  Unpermitted parameters: :utf8, :authenticity_token
  Redirected to http://localhost:3000/partners/sign_up?plan=Local
  Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
  
  
  Started GET "/partners/sign_up?plan=Local" for 127.0.0.1 at 2020-02-25 19:06:13 -0500
  Processing by Affiliates::RegistrationsController#new as HTML
    Parameters: {"plan"=&gt;"Local"}
    AffiliatePlan Load (1.2ms)  SELECT  "affiliate_plans".* FROM "affiliate_plans" WHERE "affiliate_plans"."nickname" = $1 LIMIT $2  [["nickname", "local"], ["LIMIT", 1]]
    ↳ app/controllers/affiliates/registrations_controller.rb:11
    Rendering affiliates/registrations/new.html.erb within layouts/application
    Rendered affiliates/registrations/new.html.erb within layouts/application (4.6ms)
    Rendered layouts/_google_analytics.html.erb (1.1ms)
  [Webpacker] Everything's up-to-date. Nothing to do
    Rendered layouts/_header.html.erb (1.2ms)
    Rendered layouts/_footer.html.erb (0.7ms)
  Completed 200 OK in 191ms (Views: 187.6ms | ActiveRecord: 1.2ms)
  </code></pre>