# RESTful acts\_as\_tree

**URL:** <https://www.ruby-forum.com/t/restful-acts-as-tree/153207>\
**Category:** Rails\
**Created:** [November 13, 2008, 12:36pm UTC](https://www.ruby-forum.com/t/restful-acts-as-tree/153207 "2008-11-13T12:36:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cautaro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dbc845/32.png) [@cautaro](https://www.ruby-forum.com/u/cautaro)\
**Post date:** [November 13, 2008, 12:36pm UTC](https://www.ruby-forum.com/t/restful-acts-as-tree/153207/1 "2008-11-13T12:36:53Z")

</div>

Hello,

I was trying to use the acts\_as\_tree plugin and I got stuck when  
trying to do it in a RESTful way. I have a Place model that can have  
and belong to other places. What is the correct method of creating new  
places in a RESTful way? I don’t necessarily care about have an url /  
place/id/place/id. I’m mostly interested to know the correct way of  
passing the parent\_id in order to create the new place.

This is my create method:

# POST /places

def create  
@parent\_place = Place.find(params[:place\_id])

# or do I use @parent\_place = Place.find(params[:parent\_id])

```
@place = @parent_place.children.build(params[:place])

respond_to do |format|
  if @place.save
    flash[:notice] = 'Place was successfully created.'
    format.html { redirect_to(@place) }
  else
    format.html { render :action => "new" }
  end
end

```

end

# routes.rb

map.resources :places, :has\_many =\> :places # is this legal?

Some guidance would be really appreciated. Thanks
