So, you want a quick and dirty way to obtain all the models in your Rails app that contain relations targeting a collection (like an has_many relation)?
Dir['app/models/**/*.rb'] .map {|model| File.basename(model, '.rb')} .map(&:camelize) .map(&:constantize) .select {|section| section.reflections.find {|name, reflection| reflection.collection? } }.map(&:to_s)
kind of.. ^_^
Leave a Reply