Flame
Flame

Reputation: 7619

Checking if a tablecolumn contains a certain value

Any code for checking a table-column's value? Lets say we have a table submittedpictures and it contains a column called isFinalPicture. There are 5 records, but only one of them has isFinalPicture == true. The others are all false.

How can I check this?

I already tried something like

<% if @user.games.rounds.submitted_pictures.isFinalPicture.include?(true) %>

But it didnt really work, and I'm out of ideas

Upvotes: 1

Views: 984

Answers (1)

MrYoshiji
MrYoshiji

Reputation: 54882

Maybe something like this:

<% if @user.games.rounds.submitted_pictures.where(:isFinalPicture => true).any? %>

Upvotes: 3

Related Questions