3 ms·
I really like REST most of the time, but I do have some complaints about Rails' implementation of it. I wrote about them a few years ago: http://illuminatedcom
by pjungwir 11y ago
I really like REST most of the time, but I do have some complaints about Rails' implementation of it. I wrote about them a few years ago:
http://illuminatedcomputing.com/posts/2011/07/restless-doubts/ http://illuminatedcomputing.com/posts/2011/07/restless-doubt...
Basically, after form submit errors your location bar still says /widgets or /widgets/1 rather than /widgets/new or /widgets/1/edit, so bookmarking that page, or "like"ing it, or Ctrl-L + <Enter>ing are all broken. I'd much prefer a redirect back to the correct URL.
Also the distinction between "create" and "update" can break the back button, if the user creates something, then clicks back to edit their submission (because submitting a second time will create a second thing, not update their original thing). That's not Rails so much as REST in general.
- seanp2k2 11y agoNot sure if I 100% understand, but it sounds like maybe you want to rescue the exceptions you can think of explicitly, then redirect_to previous_thing and return
- pjungwir 11y agoExactly. Something like this: if @foo.save flash[:success] = "Saved" redirect_to foos_path else redirect_to new_foo_path end The standard pattern is to `render 'new'` rather than doing the latter redirect. So I'm complaining that my preferred way isn't "blessed" by the Rails community. Also you need a trick to keep @foo.errors in between requests and load it up in your #new method the second time around.