From 0b00fa41224dc4e33b059cd0cd31cd42b022b03b Mon Sep 17 00:00:00 2001 From: Brian Stolz Date: Fri, 31 Jan 2014 15:27:34 -0800 Subject: [PATCH] Make sure we are connected before table_exists? Because otherwise it will bail because it cannot connect to a DB when doing things like precompiling assets. Test with: ``` env -i GEM_PATH=$GEM_PATH \ PATH=$PATH \ DATABASE_URL=postgres://user:pass@127.0.0.1/dbname \ /bin/sh -c 'bundle exec rake --trace assets:precompile' ``` --- lib/rolify/configure.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rolify/configure.rb b/lib/rolify/configure.rb index 9647f9ca..0d714b21 100644 --- a/lib/rolify/configure.rb +++ b/lib/rolify/configure.rb @@ -45,7 +45,7 @@ def sanity_check(role_cnames) role_cnames = [ "Role" ] if role_cnames.empty? role_cnames.each do |role_cname| role_class = role_cname.constantize - if role_class.superclass.to_s == "ActiveRecord::Base" && !role_class.table_exists? + if role_class.connected? && role_class.superclass.to_s == "ActiveRecord::Base" && !role_class.table_exists? warn "[WARN] table '#{role_cname}' doesn't exist. Did you run the migration ? Ignoring rolify config." return false end @@ -53,4 +53,4 @@ def sanity_check(role_cnames) true end end -end \ No newline at end of file +end