Updated to support rails 4