Method: Cbac::Setup.check_tables

Defined in:
lib/cbac/setup.rb

.check_tablesObject

Check to see if the tables are correctly migrated. If the tables are not migrated, CBAC should terminate immediately.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cbac/setup.rb', line 11

def check_tables
  begin
    classes = [ Cbac::PrivilegeSetRecord, Cbac::GenericRole, Cbac::Membership, Cbac::Permission ]
    return classes.all? do |c|
      c.table_exists?
    end
  rescue ActiveRecord::ConnectionNotEstablished
    # There is no database connection yet.
    puts "CBAC: Connection to database not established when initializing Cbac. Cbac is *not* running."
    return false
  end
end