Forum: Ruby on Rails Files in LIB folder do not seem to update even in DEV mode!!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris Richards (chris)
on 2006-05-08 12:11
Hi

When i change my classes in the LIB folder they are not updating on the
server.  My server is in development mode.  Any ideas why?

Any help is appreciated
Thanks,
Chris
631d1677786f0725da6ccee46043686e?d=identicon&s=25 Jonathan Viney (Guest)
on 2006-05-08 12:30
(Received via mailing list)
You need to include Reloadable in any classes that you want reloaded
with each request. Some classes, like ActiveRecord, include this
already.

class MyClass
  include Reloadable
end

-Jonny.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris Richards (chris)
on 2006-05-08 12:48
Thanks Jonny.

It seems a strange to have to do.  Surely in development mode it should
reload all your classes on each request? is this not the point of
development mode?

So, i have to inlude "include Reloadable" in the classes i want to
reload while i am developing.  And then when i go into production mode i
will remove the code.  Seems plain wrong.
6dab365a82517fb694650a57ee88e4a4?d=identicon&s=25 j`ey (Guest)
on 2006-05-08 12:58
Chris Richards wrote:
> Thanks Jonny.
>
> It seems a strange to have to do.  Surely in development mode it should
> reload all your classes on each request? is this not the point of
> development mode?
>
> So, i have to inlude "include Reloadable" in the classes i want to
> reload while i am developing.  And then when i go into production mode i
> will remove the code.  Seems plain wrong.

Model files can only reload becasue they inherit from
ActiveRecord::Base, to Rails knows about them, but it doesn't know about
files that don't inherit from that.

J`ey
http://www.eachmapinject.com
631d1677786f0725da6ccee46043686e?d=identicon&s=25 Jonathan Viney (Guest)
on 2006-05-08 14:45
(Received via mailing list)
I don't know enough about it to tell you why Rails doesn't simply
remove everything and start again, but I'm sure there are reasons.

You don't need to remove the 'include Reloadable' line when in
production. The code which reloads the classes simply isn't called
when in production. You can remove it if you want, but you don't have
to.

-Jonny.
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-05-08 15:48
(Received via mailing list)
Imagine a file in your lib folder that had this in it:

class Scary
  File.delete "/something/important.cfg"
end

..or

class Spam
  MyMailModel.deliver_spam
end

You'd want to be pretty sure you wanted to reload those automatically
before letting it happen.
This topic is locked and can not be replied to.