copied source from techindepth_rails