Way to put javascript you want to appear in the head but dec

I have some javascript that is specific to an rhtml template but must
appear
in the section. I figured I could just put it in a
variable
at the top of my template and make my layout conditionally output that
variable if it existed. But is there a better way to do this that has
already been standardized in rails?

Thanks,
Carl