# How to get rid of an ActiveRecord warning "already initialized constant"

**URL:** <https://www.ruby-forum.com/t/how-to-get-rid-of-an-activerecord-warning-already-initialized-constant/158954>\
**Category:** Rails\
**Created:** [January 29, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/how-to-get-rid-of-an-activerecord-warning-already-initialized-constant/158954 "2009-01-29T19:06:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [January 29, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/how-to-get-rid-of-an-activerecord-warning-already-initialized-constant/158954/1 "2009-01-29T19:06:33Z")

</div>

I need to get a proxy class for a specific AR validation

I reuse a piece of code (from Globalize), where it’s set as a  
constant :

module Globalize  
module Model  
module ActiveRecord  
class \<\< self  
def create\_proxy\_class(klass)  
Object.const\_set “#{klass.name}Translation”, Class.new  
(::ActiveRecord::Base){…}  
…  
end

so in my validation module, I can write :  
translation\_class = Globalize::Model::ActiveRecord.create\_proxy\_class  
(self.class)  
no problem when executing it…

but in my model unit tests, I execute it many times, and I get the  
warning…  
warning: already initialized constant EnumerationTranslation (when  
my model class is Enumeration of course)

can I delete this constant in my test setup ? how ?

thanks fyh

erwin
