Nested ARes models

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
end

and in employee.rb

class Employee < ActiveResource::Base
self.site = “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.

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