I am trying to create an ActiveRecord Object.But I\'m getting this error while creating it.
(0.1ms) ROLLBACK
ActiveRecord::StatementInvalid: PG::InFailedSql
Had similar problem after upgrading Rails from 4.2.2 to 4.2.5 I had to upgrade pg gem and problem start happening
9) WorkPolicy#is_publicly_viewable? is publicly visible hides work if deleted
Failure/Error: before { DatabaseCleaner.clean_with :deletion }
ActiveRecord::StatementInvalid:
PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
: SELECT tablename
FROM pg_tables
WHERE schemaname = ANY (current_schemas(false))
Teddy Widom Answer is right in this sense, just to sum the problem:
Sometimes when you use DatabaseCleaner.clean_with :deletion you may be interfering PostgreSQL transaction.
So solution for me was to replace DatabaseCleaner.clean_with :deletion in parts of the tests where this was caused with DatabaseCleaner.clean_with :truncation
Just one more thing for googling people. If you are noticing this stack trace:
An error occurred in an `after(:context)` hook.
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "table_rows" does not exist
LINE 1: ...ion_schema.tables WHERE table_schema = 'test' AND table_rows...
^
...it may be caused by this problem