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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to