I want to get table name in a model method. I found there should be method table_name but when I try to call it I get NameError Exception: undefined local variable or method `ta
If you are in a class method of the class you want the table name for, try:
class Model < ActiveRecord::Base def self.class_method puts self.table_name end end
If you try using
self.class.table_name
you'll run into a NoMethodError: undefined method 'table_name' for Class:Class
NoMethodError: undefined method 'table_name' for Class:Class