On 6/21/07, Bala Paranj <bparanj / gmail.com> wrote: > I have an array that contains list of attributes of a ActiveRecord > object. I have another array that contains list of values for those > attributes. > > So for a Foo object, > > attributes_list = ["first_name", "last_name"] > values_list = ["Bugs", "Bunny"] > > I have instantiated the class by: > > class_name = class_string.constantize > obj = class_name.new > > Then I just loop up through those arrays and set values to the attributes: > > obj.attribute1 = value1 > > I get: > > undefined method `attribute1=' for #<Foo:0x3326da8> > > How do I set values for the attributes? TIA. Are you trying to set the values on an instance of Foo, or on a model instance? If it's an instance of a class Foo, look at the documentation for attr_accessor.