← Back to Upcase

Rails best practices regarding redirect after CRUD operations


(Johan van Zyl) #1

I was wondering if there were any best practices for redirection after destroy, update, and create actions. Would a user prefer to be back at the show page after an update, or rather back at the index? Also, would you put your delete button on the index page next to each item listed, or rather on the show page of the item?

I currently follow this strategy:
action -> redirect to page

  1. create -> index
  2. update -> show
  3. destroy -> index

(Jameson Trinker) #2

I would put the delete button on the show page. And that may just be me, I don’t know that there is a best practice for this. I’d say show so that you’re index isn’t littered with delete buttons, but also so that you have to navigate to a another page to delete an item, making accidental deletes a bit more difficult.