Ruby on Rails automatic reload of libraries

Currently I'm busy developing a Rails Application. I'm busy developing some general classes that aren't part of a model/controller or view. I placing these classes in the 'lib' directory.
Things are fine ... well not quite ...

The problem while developing is the libraries aren't reloaded on each request. This is very frustrating when you are trying to write a library.

Some things I found (but don't seam to work):

Rest the application in the console. Well the application reset, but not the libraries.

$ ./script.console
Loading development environment...
>> Dispatcher.reset_application!

I assume the libraries directory is loaded in the ruby booting class loader. ( I'm still thinking Java ). So when Webrick starts these libs are loaded.
The models and controllers etc. are loaded by the rails class loader.

Somehow I need to reload the library in the rails class loader space.... Doesn somebody have a solution!?
Perhaps I should find another directory...

I will keep you informed if I find a solutions.

---

1 august 2007: Well found a solution for the problem, I even wonder if it really was a problem..... (shame on me)
If I place the class "MyOwnClass" in the file "lib/my_own_class.rb" without including the source file. (This isn't required, because Rails automatically includes it) it seems to be refreshed every time I do a request...

Nice.. !

Ajax Table Paginated Sortable and Searchable

Currently I'm working on an application for a client. It's build in Ruby on Rails. After using ActiveScaffold for the startup I've decided to remove this plugin and write my own Ajax table.

I found a nice article / sample about this subject: http://dev.nozav.org/rails_ajax_table.html

The article is nice for a single table, but I need multiple tables, so I need to wrap some stuff in helpers. But that shouldn't be a problem.

Agile Web Development with Rails 2nd Edition – Part 2

Wel I've almost completely read the book while I was away on a summer holiday. I still like the book. Specially the Web 2.0 part has been improved very much. Also the RESTful routes part is interesting, but I don't see the direct need for it.

I still need to read the part about deployment, but after a quick peek, I think it's much completer and more mature then the description in the first book. Also it shifted the usage advice from fastcgi to Capistrano. Well an interesting chapter.

The Ajax part also hinted me about the "readystate 3" problem, which simply means that the web server should not use keep-alive with ajax. It looks like this is the problem I've encountered with a project of mine... Need to figure this out!

Agile Web Development with Rails 2nd Edition

agile_web_development_with_rails_2nd.jpgAfter a three week wait I finally got my ordered book: "Agile Web Development with Rails, 2nd edition". I remember the bookstore salesman "The book is in stock at my supplier, it will be here in three days...". Yeah right!

Last year I bought the first edition of this book, and a few days after buying I noticed there already was a second edition on the way. I felt pretty screwed. Tried to get some discount via Dave Thomas, but unfortunately I didn't get it.. Btw. I really think Dave is great writer and great developer, he always seems to anwers his email personally. Very good!

I told myself, I will not buy this 2nd edition book, I'm not paying the money again for a lot of the same content..

Well I changed my mind, (after viewing an illegal bittorrent PDF version)

And after reading through the depot application (again) I indeed found a lot of improvements and new things about rails I didn't know!

It again is worth the money.

Some highlights of new things I read ( Btw. I still need to read 400 pages ;-) )

  • link_to has a :method parameter. (Very usefull, didn't know this)
  • rjs templates, read about them never used them. Now I can see them in the Depot application
  • Ajax based cart, with nice update effects
  • form_for construct. Didn't know it existed, but I really like it!
  • request.xhr?
  • cycle, for automaticly cycling colours!
  • ... still need 400 more page to read, the items above are only items extra in the tutorial ...

Btw. Another great book from Dave I really advice you to read is "The Pragmatic Programmer From Journeyman to Master". I've got his book a few years ago and it's full of good advice and inspiration.

The coming days I'm not behind a PC, so I will not make a lot of digital adventures... Well I wil read some more in my new Rails book...

Now Oblivion Time ...

Calendar Formatting Problems

Forget the calendar I wrote yesterday about. It isn't very easy to change the display format of the date it uses. I prefer to use a date in the form dd-mm-yyyy. Not with an English name. The project is for a Dutch client, so it isn't acceptable to show "july 11, 2007".
I've restored my original implemenation.