That was a heroic thread, umuro, thanks a lot for sharing!

Maybe it's fixed in the latest Rails? We'll check when we get to 4.2 :)

Warm regards,
Ignacio

El 30-01-2015 a las 10:15, umuro escribió:
> In my application users has books
> |Book.reverse_reflection(:owner).try :name
> => :books
> User.reverse_reflection(:books).try :name
> => :owner|
> 
> But if I edit any DRYML page then:
> |Book.reverse_reflection(:owner).try :name
> => nil|
>  
> 
>     |klass = User.reflections[:books].klass
>     => Book
> 
>     Book == klass
>     => false
> 
>     |
>     Book is not Book. I guess one is the old class before reload.
> 
>  So after classes reload, reflections are still holding the old class
> sometimes!
> 
> *SOLUTION*
> *
> *
> *config/application.rb*
> |
>     config.to_prepare do
>       BugFix.apply
>     end
> |
> 
> *lib/bug_fix.rb*
> |
> moduleBugFix
> 
> 
>   defself.apply
>     BugFix::ActiveRecord.apply
>   end
>  
>   moduleActiveRecord
>    
>     defself.apply
>       ::ActiveRecord::Base.descendants.selectdo|k|
>         k.reflections.values.each do|r|
>           r.instance_eval do
>             if@klass
>               new_klass =Object.const_get(@klass.name)
>               @klass=new_klass
>             end
>           end
>         end
>       end
>       true
>     end
>    
>   end
>  
> end
> 
> |
> 
> Now my development environment reloads the code without problems.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Hobo Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/hobousers.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to