Women in Technology

Hear us Roar

  Rolling with Ruby on Rails, Part 2
Subject:   "Showing recipes in a category" code
Date:   2005-03-20 14:27:35
From:   garrowsmith
Response to: "Showing recipes in a category" code

Can this technique be adapted... say I wanted to list all recipies but sort them alphabetically by category. Is there a neat way to do this?
Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Curt Hibbs photo "Showing recipes in a category" code
    2005-03-20 17:18:44  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

    Well, one way to do it would be to explicitly specify the SQL and use ORDER BY to do the sorting. Something like this:

    @recipes = Recipe.find_by_sql("SELECT * FROM recipies ORDER BY category_id")