hello all, i have a model which needs to instantiate a class depending on the string name which is passed to initialize()
so, to get my Person class instance, i do: person = Kernel.const_get("Person").send("new") person.class => Person
#then i have a method which returns a hash of attributes get_person_attributes.each do |att| person.send("#{att}=", get_person_attributes[att]) end
person.inspect => #<Person ....> #all the attributes look ok here
now come the problems. firstly, i tried just doing person.update_attributes(get_person_attributes), which results in:
`new_record?' for "Person":String
and doing self.save gives the same error.
the models initialize method looks like: def initialize(*args) super(*args) ...other stuff end
any ideas why i'm getting that error? I know update_attributes calls save(), so they're the same problem, but i can't figure out what's causing save to be called on the string object.
thanks for reading.