MailingList


simple fix for a simple bug, Model#reload

View: New views
1 Messages — Rating Filter:   Alert me  

simple fix for a simple bug, Model#reload

by Dominiek ter Heide :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Normally, in ActiveRecord Model#reload will return the same object -  
reloaded:

rails development>> Site.find(13).reload.class
# => Site

But when using Globalize ModelTranslations:

rails development>> Site.find(13).reload.class
# => NilClass
rails development>> Locale.set('ja-JP')
rails development>> Site.find(13).reload.class
# => Globalize::Language

Below here is a simple svn diff that adds one line to the overridden  
reload method. This might save some developers some hassle  
(especially in unit tests).

Thanks for making localization so easy guys!

Dominiek



Index: vendor/plugins/globalize/lib/globalize/localization/
db_translate.rb
===================================================================
--- vendor/plugins/globalize/lib/globalize/localization/
db_translate.rb (revision 4980)
+++ vendor/plugins/globalize/lib/globalize/localization/
db_translate.rb (working copy)
@@ -664,6 +664,7 @@
        def reload
          globalize_old_reload
          set_original_language
+       self
        end