# Nested ARes models

**URL:** <https://www.ruby-forum.com/t/nested-ares-models/172607>\
**Category:** Rails\
**Created:** [July 24, 2009, 12:13am UTC](https://www.ruby-forum.com/t/nested-ares-models/172607 "2009-07-24T00:13:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dldldl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/258eb7/32.png) [@dldldl](https://www.ruby-forum.com/u/dldldl)\
**Post date:** [July 24, 2009, 12:13am UTC](https://www.ruby-forum.com/t/nested-ares-models/172607/1 "2009-07-24T00:13:42Z")

</div>

I have two ARecord models, Company and Employee, that are both  
serviced by RESTful controllers. I want to create a nested  
ActiveResource-based front end that makes calls on this RESTful  
interface. In my front-end client routes.rb I have

map.resources :companies do |company|  
company.resources :employee  
end.

Then in my client company.rb model, I have

class Company \< ActiveResource::Base  
self.site = “[http://localhost:3000](http://localhost:3000)”  
end

and in employee.rb

class Employee \< ActiveResource::Base  
self.site = “[http://localhost:3000/companies/:company\_id](http://localhost:3000/companies/:company_id)”  
end

How do I create and save a new employee instance?

With

@company = Company.find(1)

I’ve tried

employee = Employee.new(:name =\> “Jeff”, :city =\> “Portland”,  
{:company\_id =\> @company.id})

But I just get a compile error. I don’t see what’s wrong.
