I've got a weird problem on one particular project only. Using Rhodes 220.127.116.11 and 18.104.22.168 on OSX. I'm wondering if anybody else has noticed this or has a solution? I'd imagine it's something we are doing, rather than a bug in Rhodes, but I can't figure out for the life of me what is going wrong.
The layout is being rendered in the HTTP response to all callbacks. We do not call render, and there are no ERB files whose names correspond to the callback methods.
My understanding of Rhodes layout/template rendering and callbacks is:
- The server gets an HTTP request, and matches up the URL with a controller method. It calls the appropriate controller method.
- In the controller method, if you call render, that determines what is rendered and returned in the HTTP response
- If you do not call render, then Rhodes looks for an .erb file in your controller subdirectory with a name corresponding to the method name.
- If there is no corresponding .erb file, then nothing is rendered.
- A valid HTTP header is always returned. So, "nothing is rendered" really means that a response is sent with HTTP headers and content length of 0.
- In the case of a callback (RhoTimer, AsyncHttp, etc. etc. etc.) Rhodes sends an HTTP request to the server, ultimately causing the corresponding controller method to be called. The HTTP response is ignored.
So, this problem is benign, in that it doesn't cause anything "bad" to happen - except that the layout is needlessly rendered, and inserted in the HTTP response, which will be ignored.
I noticed this only because I had set the log level to 0.
- If the controller only has callbacks, you can add:
at the top of the Controller class.
- If the controller has a mix of callbacks and pages that you want to render, you need to add:
render :string => '', :layout => false
in each callback method.
I'd rather that Rhodes didn't even put the headers in the response. There is no need for them, right? (Maybe useful if debugging by sending requests from a browser URL bar to test callbacks?)