Hey all,
There is one thing that has been bothering me about how Rails implements REST, particularly in the XML form. I'll be the first to admit that I haven't read all of Roy's dissertation but I think I have the gist of it from his presentation "The Rest of REST" (http:// roy.gbiv.com/talks/200709_fielding_rest.pdf)
One of the key things that I get from him is that its URLs that make connections between representations, and its the presence of URLs that allows us to create adaptive behaviour. So now I wonder why it is that if I have a model that belongs to another:
class Foo < ActiveRecord::Base belongs_to :bar end
I get something like the following XML from /Foos/1.xml:
<foo> <id>1</id> <bar>12</bar> </foo>
As far as I can tell, this is not RESTful, or at least not as RESTful as: <foo> <id>/Foos/1.xml</id> <bar>/Bars/12.xml</bar> </foo>
further, if we add a has_many and has_many :through to our model, such as: class Foo < ActiveRecord::Base belongs_to :bar has_many :subscriptions has_many :blogs, :through => :subscriptions end
I would expect to see: <foo> <id>/Foos/1.xml</id> <bar>/Bars/12.xml</bar> <subscriptions>/Foos/1/subscriptions.xml</subscriptions> <blogs>/Foos/1/blogs.xml</blogs> </foo>
Since Rails doesn't do this natively, how can I abuse it to make it do my will?