Let\'s say I have an Foo ActiveRecord model with fields foo_id, foo_name and foo_description.
After doin
There is an attributes method that give a hash of field and values. So you could use
@foo.attributes.keys
To get an array of the fields on the model.
There's also a Foo.column_names class method that gives you the same information without having to look up a record first.
Documentation for:
ActiveRecord::Base.column_names
ActiveRecord::Base#attributes