5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/catalogue.rb', line 5
def self.models
tables = []
ActiveRecord::Base.connection.tables.map do |model|
tables << model
end
models_in_db = []
models_not_in_db = []
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
model_name = File.basename(file, '.*')
if tables.include? model_name.pluralize
models_in_db << model_name
else
models_not_in_db << model_name
end
end
{
db_catalogue: models_in_db,
logic_catalogue: models_not_in_db,
all_catalogue: models_in_db + models_not_in_db
}
end
|