Something similar to this C# code in Ruby on Rails

Posted by Jimmy on Stack Overflow See other posts from Stack Overflow or by Jimmy
Published on 2010-06-08T02:32:23Z Indexed on 2010/06/08 2:42 UTC
Read the original article Hit count: 271

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ruby-on-rails