I have this controller method
def dashboard
method1
method2
method3
..
end
Everything is working fine in development
environment.. but in test
environment, i am getting this error after first few methods.
I checked using binding.pry
just above the line which i used to get error,
I cannot run any query eg: Account.first
but same Account.first
works in dev
environment
Error when i run in test
environment:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
: SELECT "accounts".* FROM "accounts" ORDER BY "accounts"."id" ASC LIMIT 1
from /home/qwinix/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `async_exec'
Please note the following
method1
, which executes just fine in both environment. i am getting these error after method3
which i havent touched.PS: I did google and search stackoverflow questions, didnt help
Edit: When i moved the method1
to end, i am not getting any errors, please explain me this behaviour.
Did you try to reset the Test Database?
bundle exec rails db:drop RAILS_ENV=test
bundle exec rails db:create RAILS_ENV=test
bundle exec rails db:schema:load RAILS_ENV=test
or for Rails Version older than 5
bundle exec rake db:drop RAILS_ENV=test
bundle exec rake db:create RAILS_ENV=test
bundle exec rake db:schema:load RAILS_ENV=test
or shorter:
bundle exec rake db:reset RAILS_ENV=test
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.