Sign In/My Account | View Cart  
advertisement

Article:
 Putting REST on Rails
Subject: How about joined tables?
Date: 2006-08-01 18:00:53
From: johnarmstrong

I'd like to see some more info on :has_many and :belongs_to. I hook these up and they are not automagically part of my REST output.


I think I can expose them manually in the XML but it would be nice to have the view call to .to_xml expose them.



Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • How about joined tables?
    2006-08-02 01:28:30 dkubb2

    You wouldn't necessarily want join tables to be automatically dumped via to_xml, simply because for one project a single table join is sufficient, but other projects may need to join several tables to display a resouce. There's not one approach that would satisfy all instances, and to_xml chooses the most efficient approach by default.


    For this example I used to_xml because it was simple, but in real world systems I've worked with a resource is comprised of more than just one model object. For all but the simplest resources I usually pull in several objects for the view.


Sponsored By: