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

278 views Asked by At

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.

2

There are 2 answers

0
ellawren On

The annotate gem is great for this.

2
iltempo On

Maybe Model.attribute_names is what you are looking for.