So I have one model called Project, for which there is a nested model called Proposal (so every project has multiple proposals, and each proposal only belongs to one Project).
I have a column for Proposal called “winning” which just checks if one of the Proposals has won for the Project. I’d like to reference this on the Show page of the Project, but a little perplexed by the code.
What I really want to do is check if any of the proposals have status “winning”
This is what I’m trying for the Show view for Projects, but it isn’t working:
<% if @project.proposals.winning %>
SUCCESSFUL
<% end %>
I feel like this should be pretty rudimentary but I’m having trouble figuring it out, thanks!
That’s ideal candidate for:
Enumerable.any? returns true if for any array element the block returns true.