adapte for pg and rails 4.1.5