Say I'm writing a library application for a publishing company that already has a People application.
So in my Library application I have
class Person < ActiveResource::Base
self.site = "http://api.people.mypublisher.com/"
end
and now I want to save Articlefor each Person:
class Article < ActiveRecord::Base
belongs_to :person, :as => :author
end
I assume that I will have the following table in my database:
Articles
id (PK) | title (string) | body (text) | author_id (integer)
author_id- This is not a foreign key, since I do not have a People table. This leaves a few questions:
How can I tell my object Person ActiveResourcethat it is has_many Articles?
Will it work Articles.find(:first).author? Will it work belongs_toprovided that there is no ActiveRecordand no support table?
source
share