ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  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"

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.