baash05
baash05

Reputation: 4516

Rails: How do I find out what fields are in an active record

I've got an active record class open. I want to know all the fields available to me in that class?
How can I do this quickly, without walking over to the database design document hanging on my wall?

I'm trying to wrap my head around having public data elements, obfuscated from me, but I just find it so frustrating to get at the field names available.

Upvotes: 0

Views: 579

Answers (2)

ellawren
ellawren

Reputation: 947

The annotate gem is great for this.

Upvotes: 1

iltempo
iltempo

Reputation: 16012

Maybe Model.attribute_names is what you are looking for.

Upvotes: 1

Related Questions