`category = Category.where('lower(name) = ?', category_name.downcase).first`

The code you have here is perfectly fine but will be deprecated in 4.0 (I think). It's the rails 2.x style of ActiveRecord.