using built-in rails capabilities instead of js eval (json format conversion)