relationships with remote objects

Hi guys,

I'm having an issue establishing a has_many and/or belongs_to relationship between two of my models. One of them is 'local' if you like (called site), i.e. standard model in local db, the other is a RESTful resource (called audit), defined using the self.site method. I have checked and the audit class URL is providing a 'site_id' field as expected.

When adding a 'belongs_to :site' reference to audit, I get the following error:

'app/app/models/audit.rb:3: undefined method `belongs_to' for Audit:Class (NoMethodError)'

Are relationships like this not possible?

Thanks again chaps,

Paul

paulo <paul.a.taylor84@...> writes:

Hi guys,

I'm having an issue establishing a has_many and/or belongs_to relationship between two of my models. One of them is 'local' if you like (called site), i.e. standard model in local db, the other is a RESTful resource (called audit), defined using the self.site method. I have checked and the audit class URL is providing a 'site_id' field as expected.

When adding a 'belongs_to :site' reference to audit, I get the following error:

'app/app/models/audit.rb:3: undefined method `belongs_to' for Audit:Class (NoMethodError)'

Are relationships like this not possible?

Thanks again chaps,

Paul

Looks like you're using a staright Class or ActiveRecord rather than ActiveResource. Make sure your audit class looks something like:

class Audit < ActiveResource::Base     self.site = "http://www.myawesomesite.com/&quot; end