You shouldn't have JavaScript inline in a view unless you need access to Ruby code.  Move this to the asset pipeline.  If you only need this on this page, either create an Object that's called in this document.ready or (preferable) check for this page's CSS class and only run this JS then.