It's pretty bad style to put this stuff in application.rb.  Consider moving this to other .js files that get included here.