I’m a big fan of FlagShihTzu. It allows me to combine a number of boolean attributes into one database column, saving a number of columns, indexes and a whole load of complexity. Today I even solved how to utilize the flags from a related model inside a scope. Yes, that feels pretty good.
Category Archives: rails
Z@ppelin iPad app’s massive success
I’ve been lucky enough to to be involved in the Z@ppelin iPad app as the back-end programmer. The app has seen tremendous success and is one of the most popular (if not the most popular) apps from the Dutch public broadcasters.
Relaunched: GO Magazine
I must be getting old and nostalgic. The past weeks I have been relaunching projects from my past, and GO Magazine is the first one to come online. Truth be told I am quite pleased with it.
Five essential Rails plugins
Every once in a while I post about cool plugins essential for Rails development, on the off chance you haven’t discovered them by yourself. Here’s the latest installment.
Continue reading
The value of continuous integration
It took a sweet while, but I am finally beginning to see the value in Continuous Integration. My Zelda gem is now being tested by Travis every time I push code into the repository and I can release my software with confidence.
Continue reading
Random Active Record
There is no method provided in Active Record to return a random record (to my knowledge). In the past I have used the ever so easy order by rand() for my random record needs. Problem: this is MySQL specific.
More descriptive error messages for Paperclip
Paperclip is a fine image processor for Ruby on Rails apps. However, its error messages can be a bit terse. To solve, add this to config/environments/test.rb:
Paperclip.options[:swallow_stderr] = false
Fixing ASCII-8BIT encoding for Rails 2.3 ERB
The combination of Ruby 1.9 and Rails is so much fun when it comes to character encoding. Words to adequately describe the sheer joy it gives me are hard to find. They are often four-letter though. Maybe that’s significant, I don’t know.
What I do know is this: ERB in Ruby 1.9 and Rails 2.3 will happily force all your templates to ASCII-8BIT while your database strings are most likely UTF-8. Hilarity ensues. There is no way to change this behaviour besides monkeypatching a bunch of internals.
So without further ado here are the monkeypatches: gist.
Drop in config/initializers and enjoy.
Rails on Ruby 1.9.2: every POST failing?
I ran into a nice problem today. Every POST to a Ruby on Rails on Ruby 1.9.2 app was failing. The error was nasty, too: the dreaded FAILSAFE which tells you nothing. After hunting mostly through Rack I found the culprit.
attachment_fu is not compatible with Passenger 3 on Ruby 1.9.2
Yes I know that’s an edge case, but it was true for me. Consider this code in attachment_fu:
require 'tempfile'
Tempfile.class_eval do
# overwrite so tempfiles use the extension of the basename. important for rmagick and image science
def make_tmpname(basename, n)
ext = nil
sprintf("%s%d-%d%s", basename.to_s.gsub(/\.\w+$/) { |s| ext = s; '' }, $$, n, ext)
end
end
Does that make you cry? It should.
Anyway, after removing it completely my app works fine again.
Panda Maas
I’ve developed the back end for Panda Maas, a Flash site aimed at children. The entire website is Rails 3 on SQLite with a great deal of cache optimizations.