When I generate a REST controller scaffold I get an action that looks
something like:
GET /users/new
GET /users/new.xml
def new @user = User.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end
From my understanding, the ‘new’ action initializes an instance of the
model to kind of ‘pre-populate’ the form, but nothing is saved until
the “update” action is called.
I believe the form in a typical new.erb file is just the sugar on the
cake. It is the underlying object (<% form_for @some_object %>) that
is interresting. Which you might want to fill in with some default
values. So the xml request would not ask for the form but for the
object.
It works very well with ActiveResource. ARes does not have any
knowledge of the attributes available on the remote resource. The
Controller#new method in that remote resource can help out by
serializing the attribute names and their data types.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.