Women in Technology

Hear us Roar



Article:
  Rolling with Ruby on Rails Revisited, Part 2
Subject:   filtering recipes from category list
Date:   2007-06-01 06:32:24
From:   B.Overstreet
Response to: filtering recipes from category list

The code proposed in the tutorial for list in the recipe controller didn't work.
I exchanged it by the following lines and it seems to work - even with pagination:


def list
if params[:category_id].nil?
@recipe_pages, @recipes =
paginate :recipes, :per_page => 10
else
@recipe_pages, @recipes =
paginate :recipes,
:conditions => ["category_id = ?",
params[:category_id]],
:per_page => 10
params[:category_id] = nil
end
end


Perhaps you can report your experiences with that piece of code.