I get a redefinition warning :

log warning =>
/Users/myself/Developpement/MyApp/vendor/plugins/globalize2/lib/myapp/
validations.rb:18: warning: already initialized constant
RoleTranslation

I am using the following code, apps is running well w warning
module Validations
    def validate_translation_uniqueness_of(*attr_names)
translation_class = Object.const_set "#{self.class.name}Translation",
Class.new(::ActiveRecord::Base){}
...

I tried now to avoid it writing :
translation_class = Object.const_set "#{self.class.name}Translation",
Class.new(::ActiveRecord::Base){} unless defined?("#{self.class.name}
Translation")
but it fails ...  (obviously don't like a string..)

I also tried:
translation_class = Object.const_set "#{self.class.name}Translation",
Class.new(::ActiveRecord::Base){} unless defined?("#{self.class.name}
Translation".to_sym)

"#{self.class.name}Translation".to_sym => :AccountingPeriodTranslation
which is also bad..

I need to have : #{self.class.name}Translation  giving a class , how
should I write it ?

 defined?(AccountingPeriodTranslation) =>"constant"  is what I should
test  (or any other  xxxxTranslation class where xxxx is   self.class

thanks for your help

erwin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to