Generalize and move logic out of ruby_js into Views