module ActiveSupport::Inflector
def classify(table_name)
Singular names are not handled correctly:
classify('posts') # => "Post"
classify('ham_and_eggs') # => "HamAndEgg"
convert to an actual class follow +classify+ with #constantize).
names to models. Note that this returns a string and not a Class (To
Creates a class name from a plural table name like Rails does for table
def classify(table_name) # strip out any leading schema name camelize(singularize(table_name.to_s.sub(/.*\./, ""))) end