HTTP Response Status

I’ve read this about rails actions,

‘Each action results in a response, which holds the headers and document
to be sent to the user‘s browser. The actual response object is
generated automatically through the use of renders and redirects and
requires no user intervention.’

This seems to work and make sense when a browser makes the POST, however
we have a 3D engine called Unity contrsucting an HTTP POST to our server
which passes a thumbnail of a rendered image. The controller saves the
thumnail without any trouble and the method in the controller runs to
completion however the browser isn’t redirected as it should becuase it
is Unity (the 3D player) which made the HTTP POST and not the browser.
So the parent html view which loads the player just sits there hung.

My question is, is there a way to send an HTTP Response (with a
succesful status) back to the player to let it know that the save was
succesful, and at that point we can take an action to redirect the page
in javascript from the parent view.

simplified code is as follows:
def update

    @virtual_item = VirtualItem.find(params[:id])
    @virtual_item.name = params[:name]
    if @virtual_item.update_attributes(params[:virtual_item])
      flash[:notice] = 'VirtualItem was successfully updated.'
      redirect_to :action => 'list'
    else
      render :action => 'edit'
    end

end

The attribute of @virtual_item always are successfully updated, but the
browser isn’t redirected to list. How do we send a response back to the
Unity engine which made the POST to the update method?

Thanks in advance.

On 23 Apr 2008, at 06:00, Chris M. wrote:

however
My question is, is there a way to send an HTTP Response (with a
succesful status) back to the player to let it know that the save was
succesful, and at that point we can take an action to redirect the
page
in javascript from the parent view.

Can’t your player check for a 200 (== render) or 30x (== redirect)
response. Arguably this would be a case where using the standard xml
type update would be more useful (eg if there are errors then you get
some xml describing them rather than just a web form).

Fred

Frederick C. wrote:

On 23 Apr 2008, at 06:00, Chris M. wrote:

however
My question is, is there a way to send an HTTP Response (with a
succesful status) back to the player to let it know that the save was
succesful, and at that point we can take an action to redirect the
page
in javascript from the parent view.

Can’t your player check for a 200 (== render) or 30x (== redirect)
response. Arguably this would be a case where using the standard xml
type update would be more useful (eg if there are errors then you get
some xml describing them rather than just a web form).

Fred

Yes I do believe the player can check for the response. However, it
isn’t getting any resonse back from the controller which is strange.
The page (and embedded) player just sit there waiting for a response.
We can write a event function within the player that says ‘Ok we’ve sent
our data now do something’ but that isn’t ideal. It would be nice if
it could check for a successful response and then execute the next
action we choose to take.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs