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

Then in my client company.rb model, I have

class Company < ActiveResource::Base = “http://localhost:3000

and in employee.rb

class Employee < ActiveResource::Base = “http://localhost:3000/companies/:company_id

How do I create and save a new employee instance?


@company = Company.find(1)

I’ve tried

employee = => “Jeff”, :city => “Portland”,
{: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