This Rails 3.1+ add-on lets you easily run a JavaScript function based on what controller and action is being loaded. If you'd like to contribute to this project, please fork it on GitHub and send me ...
If you are in a controlled environment and you know nothing else is going to be setting the onload event, you can register (Page.RegisterStartupScript) a script that will both set the body.onload ...