refactoring, remove rails code inside js code, use ajax instead