# Syntax to create a dependent relation?

**URL:** <https://www.ruby-forum.com/t/syntax-to-create-a-dependent-relation/152633>\
**Category:** Rails\
**Created:** [November 5, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/syntax-to-create-a-dependent-relation/152633 "2008-11-05T21:40:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [November 5, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/syntax-to-create-a-dependent-relation/152633/1 "2008-11-05T21:40:01Z")

</div>

In my controller I have this:

def new  
load\_entity  
@location = @entity.locations.build  
@site = @location.build\_site

```
respond_to do |format|
  format.html # new.html.erb
  format.xml { render :xml => @location }
end

```

end

# GET /locations/1/edit

def edit  
load\_entity  
@location = @entity.locations(params[:id])  
end

# POST /locations

# POST /locations.xml

def create  
load\_entity  
@site = @location.build\_site(params[:site])  
@location = @entity.locations.build(params[:location].datebalk!)

When I return from my form I have this in params{}

{“user”=\>{“userid”=\>“authuser”,  
“user\_id”=\>13466,  
“user\_name”=\>“A. N. Authorized-User”},  
“entity\_id”=\>“1”,  
“commit”=\>“Create”,  
“authenticity\_token”=\>“a99e941c6191c6a0897165549bb2606328472187”,  
“site”=\>{“site\_postal\_code”=\>" “,  
“site\_municipality”=\>“Hamilton”,  
“site\_street\_number”=\>” “,  
“site\_region”=\>“Ontario”,  
“site\_name”=\>” “,  
“site\_country\_code”=\>“CA”,  
“site\_building\_floor”=\>” “,  
“site\_street\_name”=\>”",  
“site\_building\_name”=\>" “,  
“site\_building\_unit\_number”=\>” “},  
“location”=\>{“location\_description”=\>” “,  
“superseded\_after\_\_dteblk”=\>”",  
“effective\_from\_\_dteblk”=\>"",  
“location\_type”=\>“MAIN”,  
“effective\_from”=\>"",  
“superseded\_after”=\>""}}

What is the correct syntax to get the hash “site” and the hash  
“location” contained within the hash “params”?
