berk / tr8n

This repository has moved to:
https://github.com/tr8n/tr8n
MIT License
280 stars 37 forks source link

ArgumentError: Tr8n is not missing constant DateRule! #17

Closed stevecrozz closed 13 years ago

stevecrozz commented 13 years ago

On 'rake tr8n:init' under rails 2.3.5, default language rules are created without proper namespacing in the 'type' column.

The following SQL query patches it up so that it works: update tr8n_language_rules set type=CONCAT("Tr8n::", type);

Here's an example exception with stacktrace from ./script/console:

Tr8n::Language.find(58).language_rules ArgumentError: Tr8n is not missing constant DateRule! from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:417:in load_missing_constant' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:inconst_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:98:in send' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:98:inconst_missing' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2197:in compute_type' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:insilence_warnings' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2195:in compute_type' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1635:ininstantiate' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:661:in find_by_sql' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:661:incollect!' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:661:in find_by_sql' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1548:infind_every' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:615:in find' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:60:infind' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:400:in find_target' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:354:inload_target' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:139:in inspect' from /usr/local/lib/ruby/1.8/irb.rb:310:inoutput_value' from /usr/local/lib/ruby/1.8/irb.rb:159:in eval_input' from /usr/local/lib/ruby/1.8/irb.rb:271:insignal_status' from /usr/local/lib/ruby/1.8/irb.rb:155:in eval_input' from /usr/local/lib/ruby/1.8/irb.rb:154:ineval_input' from /usr/local/lib/ruby/1.8/irb.rb:71:in start' from /usr/local/lib/ruby/1.8/irb.rb:70:incatch' from /usr/local/lib/ruby/1.8/irb.rb:70:in `start'

This seems to be a problem with the way default language rules are created in Rails 2.3.5. I think it comes down to Tr8n::Language.reset_language_rules! rule_class.create(:language => self, :definition => definition)

This apparently doesn't respect the rule_class' namespace which could point to a bug in activerecord in my version of rails, but maybe someone with more knowledge in this area could shed some light.

stevecrozz commented 13 years ago

This was my own fault. I was using old rails behavior which is fixed by 'ActiveRecord::Base.store_full_sti_class = true'