What are best-practices (or usual-practices) when it comes to adding more steps in a process in Rails?
For example, I am working with the Spree e-commerce Rails platform and I would like to add a multi-step form people should fill out when trying to "Add to Cart" a Product.
The current spree implementation of adding a product to the cart is basically:
ProductsController#show -> OrdersController#edit
That adds the product to the cart, and leaves you at the cart.
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:
ProductsController#show -> SurveysController#show -> (survey stuff...) -> OrdersController#edit
What I m thinking to do is:
- modify the "products/show.html.erb" so it goes to surveys_controller.rb. Also modify products_controller.rb to put
session[:redirect_to] = order_checkout_path
, which I can handle in the SurveysController. - or just make those extra things popups, and when I get to the last one, have it call the original method.
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 wizard, just adding extra things in the middle of other things.
Thanks for your help, Lance