Topic: Question on xml posts in a restful app.

Hi all,

I've been looking at php / curl calls to a very basic rest app, proof of some concepts for me; 1 table, 1 controller. I need to proove a few points before comitting to a project using RoR as it's core.

I've eventually got some php scripts talking to it; curl from the command was fine. I'm using restful_authentication and a scaffold_resource base code.

My question is just around the corner...on basecamp all xml posts are wrapped in <request>...</request> tags. E.g., for a todo list content item we send <request><content>..</content></request>

My controller and model are called program, program having a title and description field, so my xml post is <program><title>...</title></program>, this works and I'm happy with it.

So how would; and I've thought about this and not sussed it before nodding off, how would one go about adding processing in the controller to account for the request wrapper tags?

The php pear code is adding request tags to the serialized array's etc, so I guess something to strip the request tag in ruby, I just have a blank as to how to achieve this sad

What are the pro's and con's of the request wrapper tags, does it serve any purpose over the out of the box format requirements? I appreciate I maybe trying to run before walking here though. In the mean time I'm off to scour google for xml stuff for ruby smile

# POST /programs
  # POST /programs.xml
  def create
    @program = Program.new(params[:program])

    respond_to do |format|
      if @program.save
        flash[:notice] = 'Program was successfully created.'
        format.html { redirect_to program_url(@program) }
       
        #format.xml  { head :created, :location => program_url(@program) }
        format.xml do
          headers["location"] = program_url(@program)
          render :xml => @program.to_xml, :status => '201 Created'
        end
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @program.errors.to_xml }
      end
    end
  end


If somebody could feed me a little tidbit it would be much appreciated to keep my wagon on the road to RoR bliss smile

Last edited by colindensem (2007-01-14 19:27:43)