Something similar to this C# code in Ruby on Rails
- by Jimmy
Hey guys,
I am trying to get a collection of objects based on a conditions. Now normally in C# I would do something like this
employeesCollection.Where(emp => emp.Name == "john");
how can I do something similar in Ruby on Rails (I am trying to map a collection of objects to a select but I only want to map certain objects that match a condition.
My current ruby on rails code looks like this
<%= select( 'page', 'id', @post.pages.map {|page| [page.title, page.id]}) %>
I want to add a condition to an attribute of page
Can anyone help?