moving ruby code out of js file