Tag Archives: ruby hash

How to write “better” Ruby programs

I recently asked a question on Stackoverflow about when it’s best to use a case statement versus using a Hash in Ruby. I got a few answers including a really good specific answer. But another more general answer really struck me, so I’m sharing it here.
Igor Krivokon wrote:

In general, “better” in programming means different things. [...]

From ActiveRecord to Raw SQL

ActiveRecord is awesome. Its dynamic finder methods, scopes, and effortless joins make working with a database a snap. But there are always those times when writing raw sql makes more sense. In my case, I was joining across several tables, and then sorting by a value from the joined table. The problem was that my [...]