From: Mark Bush Date: 2008-03-16T04:38:42+09:00 Subject: Re: How to iterate through instance attribute names (attr_ac me wrote: > And in method validate, I'd like to iterate through all the attributes > and run their respective validating method. Is there a way for me to > be able to iterate through my list of attr_accessor symbols and > reference their names to know which method to call? If you just want to run the validates for the variables specified in the "attr_accessor" methods and not for other instance variables, then you could do something like this: class Event @@attributes = [:a, :b, :c, :d] @@attributes.each {|attr| attr_accessor attr} def validate @@attributes.each {|attr| send "validate_#{attr.to_s}" } end -- Posted via http://www.ruby-forum.com/.