<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -12,9 +12,18 @@ module Globalize
           klass_name   = module_names.pop
           target       = module_names.empty? ? Object : module_names.join('::').constantize
 
-          target.const_set &quot;#{klass_name}Translation&quot;, Class.new(::ActiveRecord::Base) {
-            belongs_to &quot;#{klass.name.underscore.gsub('/', '_')}&quot;.intern
+          proxy_class_name = &quot;#{klass_name}Translation&quot;
+          proxy_class = nil
+          begin
+            proxy_class = proxy_class_name.constantize
+          rescue NameError
+            proxy_class = target.const_set proxy_class_name, Class.new(::ActiveRecord::Base)
+          end
 
+          proxy_class.instance_eval do
+            belongs_to &quot;#{klass.name.underscore.gsub('/', '_')}&quot;.intern
+          end
+          proxy_class.class_eval do
             def locale
               read_attribute(:locale).to_sym
             end
@@ -22,7 +31,9 @@ module Globalize
             def locale=(locale)
               write_attribute(:locale, locale.to_s)
             end
-          }
+          end
+
+          return proxy_class
         end
 
         def define_accessors(klass, attr_names)
@@ -42,4 +53,4 @@ module Globalize
       end
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>lib/globalize/model/active_record.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>133da77c3c09618caffb41ba0324f81c18aabd53</id>
    </parent>
  </parents>
  <author>
    <name>Patrick Huesler</name>
    <email>patrick.huesler@gmail.com</email>
  </author>
  <url>http://github.com/joshmh/globalize2/commit/52797c99d4499bb7c43e7430099553f9ba64f67a</url>
  <id>52797c99d4499bb7c43e7430099553f9ba64f67a</id>
  <committed-date>2009-11-08T03:28:35-08:00</committed-date>
  <authored-date>2009-10-04T06:24:48-07:00</authored-date>
  <message> Check for the existence of the proxy class because it might exist already.
 Due to rails lazy class loading using const_missing I try to load the proxy class,
 if that fails I create a new one. After that, append the globalize methods to the
 class.

 I did not find a way to reproduce this error with a unit test. So here is how
 you can reproduce this:

 1. Have a model that needs translation (e.g Tag)
 2. Create a TagTranslation model and add a custom method to it (e.g slugname)
 3. ruby script/console
 4. Tag.new (Tag class is loaded and proxy class is being created)
 5. TagTranslation.new.respond_to?(:slugname) =&gt; false but should be true</message>
  <tree>8ac9d233cba20f85497ece605b5018fe79ecee29</tree>
  <committer>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </committer>
</commit>
