For example, if we want to get back a list of tag ids in our Product model to do some processing/munging:
def tag_ids sql = "SELECT tag_id FROM products_tags WHERE product_id = #{self.id} ORDER BY tag_id ASC" ActiveRecord::Base.connection.select_values(sql).collect! { |x| x.to_i } end
Voila, an array of integers. Much faster, depending on the size of your model object.