views:

33

answers:

1

My Rails app has a normal ActiveRecord "Account" model stored in the database. The model will store the URL to a remote XML file which defines some other objects.

For example, the Account has_many :galleries but the Gallery model is simply defined by nodes in the XML document. So how do I get /accounts/1/galleries to show the galleries from that account's XML?

How do I setup this relationship? I know how to do basic non-AR models, but I'm not sure how to define the association or if I need to create a Gallery model at all.

A: 

If the associations are known, you can simply create instance methods in Account using the association names.

For instance:

def galleries
  # Return a collection of Gallery
end

This would give you the allusion of having an association.

Pran