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*
module BugFix
def self.apply
BugFix::ActiveRecord.apply
end
module ActiveRecord
def self.apply
::ActiveRecord::Base.descendants.select do |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].
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.