2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/gmm_controller.rb', line 2
def index
unless defined?(@all_models)
@@all_models = {}
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each do |file|
begin
Rails.logger.info "GTM: loading #{file}"
require file
rescue
Rails.logger.error "GTM: Error loading #{file}"
end
ActiveRecord::Base.descendants.each{|m|
@@all_models[m.name] = {
:has_many => m.reflect_on_all_associations(:has_many),
:has_one => m.reflect_on_all_associations(:has_one),
:belongs_to => m.reflect_on_all_associations(:belongs_to)
}
}
end
end
@all_models = @@all_models
end
|