On Sep 10, 1:01 am, Nathan Beyer <[email protected]> wrote:
> I've changed the subject, as I think I'm honing in on the issues I'm
> running into -- the loading semantics of files in the initializers
> folder and files in the lib folder.
>
> Is there anything to keep in mind when referencing classes in the lib
> folder from an initializer? It seems like the files are loaded
> multiple times, such that things like class variables and class
> instance variables are re-initialized.

I think I've figured out the issue. The problem seems to be that in
development, the class caching was disabled by default, so the classes
were reloaded on every request, but the initializers aren't re-run,
which is can be rather painful.

-Nathan

>
> -Nathan
>
> On Sep 9, 3:40 pm, Nathan Beyer <[email protected]> wrote:
>
> > I have a trivial Singleton class in my 'lib' folder, which has some
> > instance variables that I setup by calling a configure method from an
> > initializer. The initializer seems to execute just fine and sets up
> > the singleton instance. However, when I reference that same singleton
> > instance in a controller later, the instance variables are all nil, as
> > though the class was reloaded.
>
> > I've tried to do this in various forms using class variables, class
> > instance variables, but in every scenario, it seems the classes are
> > reloaded and all of the variables are nil.
>
> > Is there something special about how initializers run?
>
> > Environment -
> > Windows Vista
> > Ruby 1.8.6
> > Rails 2.3.4
> > WEBrick
>
> > -Nathan
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to