changed it to support rails 3.1+