Adam Milligan's blog
Interesting Things
- A few people are looking for an electronics recycling center that doesn't charge an arm and a leg. Word is there are centers that will take pretty much anything electronic in San Carlos and by the Fruitvale BART.
- Ruby 1.8.6 segmentation fault: A couple teams have had trouble upgrading to the Ruby patch to fix the recent segfault bug. XML parsing and SOLR seem to be the most common culprits. They're working with EngineYard to figure out the problems.
- On a related note, EngineYard is now the official maintainer of Ruby 1.8.6.
- A few Pivots attended an RoR outreach meetup at Orange Labs this past Saturday. Sarah Allen organized the event with a focus on introducing more women to Ruby and Rails. It was, by all accounts, a great success.
- After seven months, and much rabble-rousing, this patch, refactoring the definitions of through association classes to use composition rather than inheritance, has been committed. Let this be a lesson to you: persistence can pay off.
Ask for Help
Non-numeric primary keys: fact or fiction?
We have one project that has considered using non-numeric primary keys in their MySql database. Enquiring minds want to know if this is a reasonable idea. General consensus was no:
- It makes Rails unhappy.
- It might make plugins unhappy.
- It might be slow (some debate on this; searching on an indexed string column is reportedly equal in performance to searching on an indexed numeric column in MySql).
- The benefits are unclear.
- Just don't do it. For reals.
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.







