How to configure has_many association with a non-ActiveRecord model

My Rails has a regular ActiveRecord account model stored in the database. The model will store the URL in a remote XML file that defines some other objects.

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

How to set up this relationship? I know how to make basic non-AR models, but I'm not sure how to define an association, or do I need to create a gallery model at all.

+3
source share
1 answer

, , .

:

def galleries
  # Return a collection of Gallery
end

.

0

Source: https://habr.com/ru/post/1738712/


All Articles