# RESTful routing, in-place editing, and creating new resource obj - design question

**URL:** <https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046>\
**Category:** Rails\
**Created:** [August 20, 2009, 1:32am UTC](https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046 "2009-08-20T01:32:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [August 20, 2009, 1:32am UTC](https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046/1 "2009-08-20T01:32:39Z")

</div>

I’m working on adding in-place editing of one of my RESTful resources  
and I need advice on how to make a change to the design patterns we  
all know and love for the creation/editing of a new resource object.

Out of the box, Rails gives you the ‘new’ and ‘create’ actions for  
creating a new resource object. This is fine for when you want a  
separate page for initial creation and subsequent editing of that  
resource.

But, now with in-place editing, my edits take place via the ‘show’  
view with AJAX handling of those in place edts.

So, what’s the approach for when the user goes to create a new  
resource obj?

I thought I could just redirect from the ‘new’ action to the ‘show’  
action after creating the new obj, but with RESTful routing this takes  
me to the index view.

Anybody know how to do this?

Or is it best practice to still have a full page edit form for the  
initial edit and only go to in-place editing for subsequent edits?

* * *

A second issue involves validations… If I am able to do the in place  
edit at creation, I have to create a new object for the ‘show’ action,  
but there isnt any data actually entered prior to going there, so I  
cant save the object because it wouldnt validate… so is there a way  
to pass the unsaved object to the show action in this case?

---

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [August 20, 2009, 7:01pm UTC](https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046/2 "2009-08-20T19:01:21Z")

</div>

I believe that in this tutorial lie the answers to some if not all of  
your questions:  
[http://www.buildingwebapps.com/learningrails](http://www.buildingwebapps.com/learningrails)

I followed it a little while back and it clicked a lot of things about  
Rails for me, and it does talk about in-place editing among others.  
Check it out, it may just be what you’re looking for 🙂

---

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [August 21, 2009, 8:05am UTC](https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046/3 "2009-08-21T08:05:24Z")

</div>

Thx, Aldric… but, could you pt me to the specific page for the  
tutorial you mentioned?

On Aug 20, 10:01 am, Aldric G. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [August 21, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046/4 "2009-08-21T17:31:15Z")

</div>

lunaclaire wrote:

> Thx, Aldric… but, could you pt me to the specific page for the  
> tutorial you mentioned?
> 
> On Aug 20, 10:01ï¿½am, Aldric G. \<rails-mailing-l…@andreas-

If you’re familiar enough with rails to read and understand, you’ll want  
to at least read lessons 10 and on to understand how they’re building  
their app (it’s pretty quick):

[http://www.buildingwebapps.com/podcasts/6663-putting-the-page-contents-into-the/show\_notes](http://www.buildingwebapps.com/podcasts/6663-putting-the-page-contents-into-the/show_notes)

Until you get to lesson 14:

[http://www.buildingwebapps.com/podcasts/6746-using-textile-markup-plus-in-place-editing/show\_notes](http://www.buildingwebapps.com/podcasts/6746-using-textile-markup-plus-in-place-editing/show_notes)

---

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [August 24, 2009, 11:50pm UTC](https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046/5 "2009-08-24T23:50:11Z")

</div>

for anyone else looking into this…

I guess I didnt find my answers on best practices for this, but I  
solved the RESTful routing to my index page by creating a named route  
for creating the new resource and going right to its ‘show’ action/  
view.

Also, to solve the initial validation prob, I just stuff it with  
valid, dummy data and then let the user edit it.

On Aug 21, 8:31 am, Aldric G. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [August 24, 2009, 11:33pm UTC](https://www.ruby-forum.com/t/restful-routing-in-place-editing-and-creating-new-resource-obj-design-question/174046/6 "2009-08-24T23:33:48Z")

</div>

for anyone else looking into this…

I guess I didnt find my answers on best practices for this, but I  
solved the RESTful routing to my index page by creating a named route  
for creating the new resource and going right to its ‘show’ action/  
view.

Also, to solve the initial validation prob, I just stuff it with  
valid, dummy data and then let the user edit it.

On Aug 21, 8:31 am, Aldric G. \<rails-mailing-l…@andreas-
