I want to shuffle things around so that routes and observers are loaded last, after plugins, the after_initialize callbacks, and the application initializers. Here''s the problem: 1) I add a gem (has_finder) to a file in config/initializers 2) It is used in my User model 3) AR initializes my UserObserver model, which loads User, before the config/initializers run 4) BOOM, undefined method #has_finder This issue is easily worked around, but this small change in the load order makes sense to me. http://dev.rubyonrails.org/attachment/ticket/10980/load_order.diff Can anyone think of any issues? -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I think this would also fix this issue: http://robsanheim.com/2008/01/08/rails-observers-make-rake-dbmigrate-crash-from-version-0/ - Rob On Feb 1, 2008 3:41 PM, Rick Olson <technoweenie@gmail.com> wrote:> > I want to shuffle things around so that routes and observers are > loaded last, after plugins, the after_initialize callbacks, and the > application initializers. Here''s the problem: > > 1) I add a gem (has_finder) to a file in config/initializers > 2) It is used in my User model > 3) AR initializes my UserObserver model, which loads User, before the > config/initializers run > 4) BOOM, undefined method #has_finder > > This issue is easily worked around, but this small change in the load > order makes sense to me. > > http://dev.rubyonrails.org/attachment/ticket/10980/load_order.diff > > Can anyone think of any issues? > > -- > Rick Olson > http://lighthouseapp.com > http://weblog.techno-weenie.net > http://mephistoblog.com > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 1, 2008 1:03 PM, Rob Sanheim <rsanheim@gmail.com> wrote:> > I think this would also fix this issue: > > http://robsanheim.com/2008/01/08/rails-observers-make-rake-dbmigrate-crash-from-version-0/ >Well, let me know... that would be a plus. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 1, 2008 1:41 PM, Rick Olson <technoweenie@gmail.com> wrote:> Can anyone think of any issues?+1. Even if there are issues, it''s still the right thing to do. "Initialization" should happen first. -- Chad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 1, 2008, at 9:41 PM, Rick Olson wrote:> I want to shuffle things around so that routes and observers are > loaded last, after plugins, the after_initialize callbacks, and the > application initializers. Here''s the problem: > > 1) I add a gem (has_finder) to a file in config/initializers > 2) It is used in my User model > 3) AR initializes my UserObserver model, which loads User, before the > config/initializers run > 4) BOOM, undefined method #has_finder > > This issue is easily worked around, but this small change in the load > order makes sense to me. > > http://dev.rubyonrails.org/attachment/ticket/10980/load_order.diff+1 Instantiating an observer triggers loading its observed model class to register it, and I think the model class should be allowed to expect full initialization. Particularly we are concerned here with extensions to Active Record by plugins or initializers. If you happen to be creating observed models in config/initializers you can still manually instantiate the singleton. So there''s some price here, but you still have a simple solution, and I believe the use cases above are far more important. I''ve added a documentation patch: http://dev.rubyonrails.org/attachment/ticket/10980/document_observers_loading.diff -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the input, everyone. I just committed it. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 2, 2008 12:19 PM, Rick Olson <technoweenie@gmail.com> wrote:> Thanks for the input, everyone. I just committed it.I also got another suggestion from Sven that the after_initialize hook should run *after* the config initializers. That makes sense to me, personally. So, please let me know if either of my changes breaks something. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---