Ruby train system using psql