cleaning up data passing between rails and javascript