begin conversion to rails. old code in /old