Skip to content

Commit

Permalink
swap connection check with ORM check first to make it Mongoid compatible
Browse files Browse the repository at this point in the history
connected? method doesn't exist in Mongoid
refs RolifyCommunity#222
  • Loading branch information
EppO committed Feb 1, 2014
1 parent 0b00fa4 commit befc8db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rolify/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit befc8db

Please sign in to comment.