Iterate over some_model_instance.attributes ?
Yeah! I guess that will then be something like...
some_model_instance.attributes.each { ... }
Going to try that...
Thanks, Fred!
(do you ever stop working...?
Or Student.column_names.each {|column| puts "#{column} = #{student.send(column)}" }
You might display something like column.humanize.downcase if you need 'date of birth' with the spaces.
-Rob
Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com
Thanks a bunch, guys!
Tom,
You may try the inspect() way:
inspect()
Returns a string like ‘Post id:integer, title:string, body:text‘
# File vendor/rails/activerecord/lib/active_record/base.rb, line 1348 1348: def inspect 1349: if self == Base 1350: super 1351: elsif abstract_class? 1352: "#{super}(abstract)" 1353: elsif table_exists? 1354: attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', ' 1355: "#{super}(#{attr_list})" 1356: else 1357: "#{super}(Table doesn't exist)" 1358: end 1359: end
Cheers, Sazima