@recipes = Recipe.find(:all, :conditions => ''vegetarian =
1'')
Jacquie Fan wrote:>
>
> 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!
>
> --
> 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---