Returning a list from the database, refined by a column

I’m creating a basic cookbook app, and I allow users to choose whether
or not the recipe is vegetarian (entered into the database column
vegetarian as 1), vegan (entered into the database column vegetarian as
2), or neither (entered into the database column as 0).

I’d like to have a page that lists only the vegetarian recipes (rows in
the database “recipes” where the value of recipe.vegetarian is 1).

I’m a newbie, so I can get all recipes out of the database in the view
with:

<% @recipe.each do |recipe| %>

How do I get it to only list recipes where recipe.vegetarian == 1? I
just don’t get the exact syntax.

Thanks!

@recipes = Recipe.find(:all, :conditions => ‘vegetarian = 1’)

Jacquie F. wrote:

I’m a newbie, so I can get all recipes out of the database in the view
Posted via http://www.ruby-forum.com/.


View this message in context:
http://www.nabble.com/-Rails--Returning-a-list-from-the-database%2C-refined-by-a-column.-tf2620078.html#a7312180
Sent from the RubyOnRails Users mailing list archive at Nabble.com.