Women in Technology

Hear us Roar



Article:
  Rolling with Ruby on Rails, Part 2
Subject:   Better way of filtering Recipes by Category
Date:   2005-05-22 12:34:49
From:   lewinke
Response to: Better way of filtering Recipes by Category

I'm not sure that this is any better but here is what I ended up with:


Adding this method to RecipeController

def list_category
@recipes = Recipe.find_all_by_category_id(@params['id'])
render_action "list"
end


And changing list.rhtml to make the category a link



<td><%= link_to recipe.category.name, :action => "list_category", :id => recipe.category.id %></td>


This could be HUGELY wrong since I've only spent about 45 minutes with rails and no time with ruby before that.