Ruby Fleebie

Rediscovering the joy of programming

Category: short & sweet

Make sure you are not using methods like “1.day.ago” when dealing with a Date column

TL;DR: Read the title ;) I spent too many hours debugging a feature spec in an application. Turns out I was simply not paying attention to what I was doing! In a fixture file, I was setting a field the following way: some_date: I didn’t pay attention to the fact that “some_date” was a Date [...]

Run bundle install with the –binstubs option

It’s been a little while that I have decided to always extract my gem binaries into my rails application “bin” path. That way, I always execute binaries by specifying the relative path. For example “./bin/rails g model User”. At first I wasn’t sure about the idea. I was like: “Wait a minute! I will have [...]

Nested has_many :through

Hi (Oh my God… he just started his blog post with ‘Hi’), Did you know that as of Rails 3.1, you can have nested has_many :through clauses in your models? Here is a concrete example to understand what I mean: