views:

26

answers:

2

In a standard generated scaffold project, when you are on an edit page, the URL looks like;

/something/3/edit

However, when the page doesn't validate, it runs the following code:

   format.html { :action => "edit" }

and the page url changes to;

/something/3

(no /edit)

Why is this is this and how to prevent it, as it looks inconsistent to me and thus confusing.

Thanks

A: 

Are you sure when fails the code is format.html { :action => "new" }?

It should be

format.html { :action => "edit" }

I checked it in my own scaffolded code and I get "edit" instead of "new" on that line.

Hope this helps.

pablorc
no change about that. It's just the file read. Not URL
shingara
+2  A: 

It's because the rendering not change the URL.

When you made an update you made :

PUT /something/3

So if it's failed, there are no URL changing. just rendering of your action file ( not action code ).

So if you want have /new of /edit you need made a :

redirect_to :edit

In this case, you lost all information like object.errors.

shingara
Yes, I saw that, but isn't that rather clunky? /edit should be the edit url, not suddenly without edit. I haven't seen this behavior with other frameworks yet, it seems fundamentally wrong to me. But thank you for your help.
CharlesS
this behaviour is REST compliant.
shingara