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:
1 12As far as I can tell, this is not RESTful, or at least not as RESTful
as:
/Foos/1.xml
/Bars/12.xml
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:
/Foos/1.xml
/Bars/12.xml
/Foos/1/subscriptions.xml
/Foos/1/blogs.xml
Since Rails doesn’t do this natively, how can I abuse it to make it do
my will?