activeresource problems

I have been experimenting with active resource recently but came across a problem. I receive a 404 error when trying to create a new object. The prescription object belongs to a device object.

Processing PrescriptionsController#create (for 127.0.0.1 at 2008-02-24 20:41:06) [POST]   Session ID: 7bb36ceab59dfac446b7d21dd3c6a45e   Parameters: {"format"=>"xml", "action"=>"create", "controller"=>"prescriptions", "prescription"=>{"device_id"=>4, "count"=>4}}

ActiveRecord::RecordNotFound (Couldn't find Device without an ID):

I have an activeresource class definition that looks like

class Prescription < ActiveResource::Base   self.site = http://www.WEBHOST.com' #modified end

Then issue Prescription.create(:device_id => 1, :count => 1) which raises the above error. Other class definitions work flawlessly. What might be going on?

after recreating the entire model step for with Rails project using the recomended nested resources method my project now looks like.

I am using nested resource defined in routes.rb map.resources :devices do |device|   device.resources :prescriptions end

I define the network class definition for Prescription as

class Prescription < WebResource self.site += "/devices/:device_id/" end

This should allow for calls like Prescription.find(:all, :device_id => 1) or Prescription.create(:device_id => 1, :drug_id => 4)

Unfortunatly it fails with a 404 error the log has ActionController::RoutingError (No route matches "/devices// prescriptions.xml" with {:method=>:post}):

Why is the device_id parameter not being passed?