Say that I have a data model called Widget. If I pick one widget…
widget = Widget.find(1)
… then I can get its attributes with widget.attributes.keys.
But what if I don’t want to find a Widget?
Is there a way to list all the attributes of the Widget class (which inherits from ActiveRecord::Base) without having to retrieve one particular Widget first?
You can get attributes directly from data model: