title: Inserting Controller Actions between Actions in Rails - Best Practices
body: <p>What are best-practices (or usual-practices) when it comes to adding more steps in a process in Rails?</p>
  
  <p>For example, I am working with the <a href="http://spreecommerce.com/" rel="nofollow noreferrer">Spree e-commerce Rails platform</a> and I would like to add a multi-step form people should fill out when trying to "Add to Cart" a Product.</p>
  
  <p>The current spree implementation of adding a product to the cart is basically:</p>
  
  <p><code>ProductsController#show -> OrdersController#edit</code></p>
  
  <p>That adds the product to the cart, and leaves you at the cart.</p>
  
  <p>So I'm wondering, in order to most-minimally change the core code in spree, how do I make it so the process is more like this:</p>
  
  <p><code>ProductsController#show -> SurveysController#show -> (survey stuff...) -> OrdersController#edit</code></p>
  
  <p>What I'm thinking to do is:</p>
  
  <ul>
  <li>modify the "products/show.html.erb" so it goes to surveys_controller.rb.  Also modify products_controller.rb to put <code>session[:redirect_to] = order_checkout_path</code>, which I can handle in the SurveysController.</li>
  <li>or just make those extra things popups, and when I get to the last one, have it call the original method.</li>
  </ul>
  
  <p>What's wrong with that?  What is a better approach?  This is a question about, more generally, how people go about architecting multistep processes without modifying core code.  Not a <a href="http://github.com/jeffp/wizardly" rel="nofollow noreferrer">wizard</a>, just adding extra things in the middle of other things.</p>
  
  <p>Thanks for your help,
  Lance</p>