I want to find all models in all namespaces.
Ideas I’ve considered:
-
Object.constantsis not working a good starting point because it does not find my namespaced modules. So this answer isn’t working for me. -
ObjectSpace is a possibility but I’d rather not use it unless necessary, since it seems less portable across Ruby implementations. (See also: ObjectSpace is disabled by default in JRuby.)
Object.constantsonly shows loaded constants. So I needed to do this first:Dir["#{Rails.root}/app/models/**/*.rb"].each { |path| require path }