From befc8db8d1894cc2fe86407dbedc1aebb3f3592f Mon Sep 17 00:00:00 2001 From: EppO Date: Sat, 1 Feb 2014 12:09:11 -0500 Subject: [PATCH] swap connection check with ORM check first to make it Mongoid compatible connected? method doesn't exist in Mongoid refs #222 --- lib/rolify/configure.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rolify/configure.rb b/lib/rolify/configure.rb index 0d714b21..28fbc7a7 100644 --- a/lib/rolify/configure.rb +++ b/lib/rolify/configure.rb @@ -45,12 +45,16 @@ 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.connected? && role_class.superclass.to_s == "ActiveRecord::Base" && !role_class.table_exists? + if role_class.superclass.to_s == "ActiveRecord::Base" && role_table_missing?(role_class) warn "[WARN] table '#{role_cname}' doesn't exist. Did you run the migration ? Ignoring rolify config." return false end end true end + + def role_table_missing?(role_class) + role_class.connected? && !role_class.table_exists? + end end end