Rails - do a logic operation on each row of an activerecord result

I have a model that has a column of type Boolean.

It's possible to retrieve "on the fly" (without iterating all the result) the result of a logic calculus?

For example:

data = Model.limit(10)
# I would like to know if each data.column is true
# the result is something to this logic: data[0].column && data[1].column && ...
# ..but there is one manner to do this without iterating?

Using the main conditions: AND, OR, XOR (the conditions are all the same - all AND or all OR ,...).


records = Model.limit(10).all
records.all? { |r| r.column? } 

I think all? is what you're looking for.

Need Your Help

Limit length post wordpress

php wordpress

Hi all I have a site in wordpress and I want to limit the character of the preview post different from default for example obnly 5 characters.

how to export register from a table with autonumber iD?

sql-server database-design autonumber

I have a database which all the tables have as ID a autonumeric field. I think that is the best option, but if I need to export data from a database to another, how can I do that? Because I can ins...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.