PG::UndefinedTable: ERROR: relation "users" does not exist

rails

#1

My test are running fine on my development environment however when they run in CircleCi they are giving this strange error:

ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation “users” does not exist
LINE 5: WHERE a.attrelid = ‘“users”’::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = ‘“users”’::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

I’m using Rspec tests with ruby on rails, capybara, factorygirl and poltergeist.
Any ideas on why this might be happening?


#2

Anyone? :frowning:


#3

Ok I figured it out.
I’m using factorygirl in my tests and it looks like that was what was giving this error.
So the solution was to update the Gemfile like so:

gem "factory_girl_rails", :require => false

and on the spec_helper.rb file add the line:

require 'factory_girl_rails'

and that’s it :wink:


#4