Is it possible to call the include? function on a whole table, like this?
<% @user.games.each do |g|
@@latestround = g.rounds.order('created_at DESC').first
%>
<% if @@latestround.submittedpictures.isFinalPicture.include?(true) %>
<p>FinalPicture has been played!</p>
<% end %>
<% end %>
The problem i’m getting is that It only works when I put a block on submittedpictures and then loop through each record of this table. However I want to look through the whole table in one go and see if the column ‘isFinalPicture’ includes a value with ‘false’.
Any ideas?
The following snippet works but its not the way i want it (I would get more lines if the round happens to have more ‘true’ FinalPictures)
<% @@latestround.submittedpictures.each do |s| %>
<% if s.isFinalPicture == true %>
<p>Final Picture has been played!</p>
<% end %>
<% end %>
You could make a scope for it like
then you could see if there is any with only one query
Also you should follow the conventions of Rails in naming your Models and everything else. Like submittedpictures should be submitted_pictures