vendredi 22 avril 2016

Rails 4 IF check syntax

I am trying to make two checks again the database and I am getting method errors.

    <% if @person.subordinates.position.any == 'grad' %>
        <h3>Neuro Grads</h3>
        <table>
        CONTENT
        </table>
    <% end %>

And the second one is much of the same content but with a double check...

<% if @person.subordinates.position.any == 'nn-grad' or 'nn-postdoc' %>

In the first area I need to check if there are any @person.subordinates.position that are listed as grad in the database. In the second area, I need to check if it is either of the two positions.

Aucun commentaire:

Enregistrer un commentaire