Syntax to create a dependent relation?

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”?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs