This patch updates the scaffold_resource template for a controller, to expand the "new" action. The "new" action is given an XML respond_to block that returns the XML version of a new instance of the model.
The purpose is to provide a "schema" for a model, for a client using this model through REST remotely. The object is to give a REST client the ability to automatically figure out attributes and types, much the same as ActiveRecord uses the database. This becomes more important for clients written in languages other than Ruby, including strictly typed languages.
An example of this in a User controller:
# GET /users/new
# GET /users/new.xml
def new
@user = User.new
respond_to do |format|
format.html # new.erb
format.xml { render :xml => @user.to_xml }
end
end
This will produce XML looking something like this:
<?xml version="1.0" encoding="UTF-8"?>
<user>
<active type="boolean"></active>
<created-at type="datetime"></created-at>
<email></email>
<middle-name></middle-name>
</user>
Discussion on core leading up to this:
http://groups.google.com/group/rubyonrails-core/browse_thread/thread/e36b84f9c1c3fe38