With the newest release version of rails I can specify a reloadable? method in my dynamic class it that appears to work, but now the problem is that methods defined in classes from associations in the dynamic class don't exist.
For example... class Dynamic < ActiveRecord::Base belongs_to :user def self.reloadable? false end end class User < ActiveRecord::Base def name "my name" end end So the class now exists on subsequent requests, but if i do this (d is an instance of class Dynamic)... d.user.name I get an undefined method error for name. This does not occur on an initial request after starting the server, but only on subsequent ones. What's going on here? Thanks, Andrew On 8/9/06, Nicholas Seckar <[EMAIL PROTECTED]> wrote:
In trunk from two days ago, any class which includes Reloadable and responds true to reloadable? will be unloaded at the end of your request. To prevent their unloading, define reloadable? to return false on your dynamic classes. If you are using trunk's latest, you shouldn't have this problem. Reloadable is no longer included into AR::Base and friends. Instead, only constants that are loaded via const_missing will be unloaded. Upgrading to trunk should solve your problem, but it's pretty fresh code. I'm not saying it's full of bugs, but it's not guarenteed to be as solid as you might expect. On 8/9/06, Andrew Kaspick <[EMAIL PROTECTED]> wrote: > Hello all, I'm having a problem with some dynamic classes that I'm trying to use in my development environment. My app is creating some dynamic classes that descend from ActiveRecord::Base. Now this part works fine, except that they only exist for the life of one request in my development environment and then they no longer exist. I'm calling a method from my environment.rb to to do the initial class creation. My current approach to recreating these classes is to use const_missing if the classes aren't found, but I'm not having very much success with this approach. I'm not sure this is even a safe approach to solving my problem, so I was wondering if somebody (with more in depth knowledge of how classes are reloaded) can give me a few pointers on things I should be looking for, trying. I can post some code if needed, but maybe there are some general guidelines I should be following to begin with. Thanks, Andrew _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
_______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core