All threads / Order confirmation page in rails

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Order confirmation page in rails

Felender Hlungwani asked in Rails

I've been trying to create an order confirmation page for my rails app, and am not quite sure how to go about it in a restful way.

There were a few answers on this question that got me halfway there, but the problem was that I wasn't quite sure how to set up the form in the rails view so that it would take the user to a confirmation page with all their details instead of a create action.

What things should I be doing to direct the user to a confirmation page that shows all the order details?

Thanks!

Hey Felender,

You need a new action in your controller that will handle the confirmation and then update your current form to GET the confirmation action instead of the create action. Then on your confirmation page, you'll replicate the form again, and this time have it POST to the create action once the user approves the transaction. Don't forget to add the route to handle the confirmation.

There's probably room for debate as to which request method to use for the confirmation action. I personally say GET just because we're not modifying any records or saving anything yet, but I'm hardly an authority on the matter :)

Check: http://www.restapitutorial.com/lessons/httpmethods.html

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 38,558+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.