Your error message stands that 'FooObject' class cannot be located.
In your code, the dynamic generated class name shoudl be 'FooDynObject'.
Just check you don't have old test records in your database before loading DynObject.
@edit: Another thing is also to know on which class you affect the dynamic class name.
class DynObject < ActiveRecord::Base
const_set 'FooDynObject', Class.new(DynObject)
end
Will result in DynObject::FooDynObject, and ActiveRecord won't be able to load it when it will see 'FooDynObject' type.
Personnally, I would do someting like
class DynObject < ActiveRecord::Base
Object.const_set 'FooDynObject', Class.new(DynObject)
end