13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/schema_sherlock/model_loader.rb', line 13
def find_model(name)
ensure_rails_loaded!
klass = name.safe_constantize || name.camelize.safe_constantize
unless klass
raise SchemaSherlock::Error, "Could not find model: #{name}"
end
unless klass < ActiveRecord::Base
raise SchemaSherlock::Error, "#{name} is not an ActiveRecord model"
end
unless klass.table_exists?
raise SchemaSherlock::Error, "Table for #{name} does not exist"
end
klass
end
|