Alex Wayne
2006-Aug-22 17:00 UTC
[Rails] Inheritance breaks in dev mode - Dependency reloading bug?
I have a plugin that creates an abstract ActiveRecord class that other models are to inherit from. module MyPlugin class MyClass < ActiveRecord::Base self.abstract_class = true # methods end end Then the use of the plugin simply has to do the following to use it''s functionality: class Foo < MyPlugin::MyClass end The problem is in the development environment. Apparently some systems are getting a "uninitialized constant MyClass" error after the first request, but works fine on other systems. It''s like Rails is wiping out the definition for MyPlugin::MyClass but never reloads it. My init.rb simply requires the file and doesn''t do anything tricky with it that might only be executed at load time. It DOES WORK however if I rename the class so it''s not in the namespaced module. Meaning instead of MyPlugin::MyClass, MyPluginMyClass. This seems to solve the issue, but I really don''t like from a purely semantic point of view. I really want all the code for this plugin to be inside this single name spaced module. Is this a bug in dependency reloading? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Chris Wanstrath
2006-Aug-22 19:09 UTC
[Rails] Re: Inheritance breaks in dev mode - Dependency reloading bug?
On Aug 22, 2006, at 10:00 AM, Alex Wayne wrote:> I have a plugin that creates an abstract ActiveRecord class that other > models are to inherit from.Try putting your file into vendor/plugins/your_plugin/lib/my_plugin/ my_class.rb instead of your_plugin/lib/my_class.rb when its MyPlugin::MyClass. When there''s a module involved, Rails'' autoloading assumes a directory. -- Chris Wanstrath http://errtheblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Alex Wayne
2006-Aug-22 20:46 UTC
[Rails] Re: Inheritance breaks in dev mode - Dependency reloading bug?
Ah thank you that was indeed the problem. And it was working on edge, and not 1.1.6 because the new Dependency code does not have this limitation. Thanks for the help! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---