Adam Milligan's blog
We've had some trouble with test task errors causing failing builds on our continuous integration boxes ever since the release of the version 0.8.3 rake gem. Sound familiar? Read on!
Interesting Things
We have a project that generates a lot of highly precise floating point numbers. However, we primarily want to display these numbers with only two decimal places of precision. In addition, we want to display these numbers with standard comma delimiters to the left of the decimal point.
Sadly, the Ruby #sprintf method provides the former functionality, but not the latter. What to do? Use a Rails helper, of course.
The NumberHelper from ActionView provides some useful functionality, so we used that. As it turns out, we found the best way to get the formatting we want to be using the #number_to_currency function with no denomination.
Also, rather than mixing the entire helper into the Float class for just one method, we chose to mix the helper into a nested class and expose only the functionality that interests us. The result looks something like this:
class Float
class RailsNumberHelpers
extend ActionView::Helpers::NumberHelper
end
def formatted
s = Float::RailsNumberHelpers.number_to_currency(self, :unit => '', :precision => 2).chomp('0')
end
end
Interesting Things
- ARMailer and ExceptionNotifer: A match not so much made in heaven.
If you use the ExceptionNotifier plugin (and if you don't, why not?) and you install the ARMailer plugin, your app will stop sending the exception notifications. You have been warned. Initial reports suggest that fixing the problem is relatively straightforward.
For those not in the know, ARMailer is a plugin that queues all outbound email in your database, to be sent later by a cron job or something similar. Good for not clogging up your server with email processing during peak load.
Ask for Help
"Is it okay to load a Flash widget multiple times on a single page?"
General murmuring led to the conclusion that this works fine.
We've uploaded a new version of the Desert gem on to RubyForge. This fixes the issues with template loading in Rails 2.1.0 and later.
From the changelog:
- Fixed exception in testspec.rake when rspec is not loaded
- Fix template loading on Edge Rails and on Rails 2.1.0
The Desert source is available on GitHub here.
The Gem is on RubyForge here.







