How to find a model class from its table name?

activerecord, ruby-on-rails

Solution

The method called to do this in Rails is #classify (http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-classify). If you can use Ruby (or Rails itself), just do the following:

"table_name".classify

or to actually get the class name:

"table_name".classify.constantize

Problem

This question is reverse of this question: How to determine table name within a Rails 3 model class . My intention is to look at Rails project database and try to figure out all possible model classes the project is related to. I have few clues, such as to get table name list from AR connection, etc. But down to table_name -> model class mapping. I got no idea. Thanks.

Original source

Related problems