Lessons for Rails: Pay attention to plugins and test everything

So I had mentioned that I had encountered difficulties with Rails 2.1 partial updates and I was suspicious of it being related to a plugin. Turns out the flextimes plugin was causing partial updates to not work as well as other subtle errors. The plugin was employed simply to enable a 12-hour with am/pm timeselect and selecttime functions. It had worked fine for a long period of time and only really caused problems with partial updates. However, once I started putting more tests into place I found other problems leading me to believe that flextimes probably broke functionality under Rails 2.0, The problem with unmaintained plugins is that they may continue to do their task but create seemingly unrelated problems elsewhere in the code.

One problem I found was that Time fields could not be updated within a model function without the value being reset upon exit. This led to my creating some very simple tests for basic functionality. I wish such tests were not necessary but they seem to be. Always be careful of plugins and examine their code looking for meta programming, particularly when they override aspects of ActiveRecord or a core Ruby class. Such things are often necessary to create the elegance that certain plugins possess but they would be a good place to start looking when errors occur. Also it is wise to use well-maintained plugins and replace those which do not have a large user base and regular maintenance.

Instead of flextimes, which has not been updated since 2006 or 2007, I used the 12 hour time plugin to accomplish my needs. The trunk version works for Rails 2.1 and they have another version for Rails 2.0. With Rails being a moving target some changes create incompatibilities which much be addressed. Of course this code itself is not complex or lengthy enough that I couldn’t write it myself but then I would be responsible for tracking changes to Rails. So far I feel this has lessoned my work time to achieve the desired functionality.

Trackback URL for this post:

http://hightechsorcery.com/trackback/152
Creative Commons License Except where otherwise noted, content on this site is licensed under a Creative Commons by-nc-sa 3.0 License