title: EJS just outputs the first found user in some cases
body: <p>I'm Using mongoDB and ejs to display all my users in a table. The table also has some action buttons to delete the user and to change the users role. The buttons open a popup to change the role or to confirm the deletion. But EJS doesn't pass the users info into the popup. It works totally fine in the table, but not in the popup.</p>
  <p>My EJS User Table with the Role change Popup:</p>
  <pre><code>&lt;tbody&gt;
                    &lt;%users.forEach(function(users){%&gt;
                    &lt;tr&gt;
                      &lt;td&gt;&lt;%=users.name%&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;%=users.username%&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;%=users.createdAt%&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;span class=&quot;badge label-table badge-&lt;%=users.role%&gt;&quot;&gt;&lt;%=users.role%&gt;&lt;/span&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;span class=&quot;badge label-table badge-&lt;%=users.verifyEmailToken%&gt;&quot;&gt;&lt;%=users.verifyEmailToken%&gt;&lt;/span&gt;&lt;/td&gt;
                      &lt;td&gt;
                        &lt;button type=&quot;submit&quot; class=&quot;btn btn-xs btn-success&quot; data-toggle=&quot;modal&quot; data-target=&quot;#con-close-modal&quot; name=&quot;changeRoleButton&quot;&gt;&lt;i class=&quot;remixicon-user-settings-line&quot;&gt;&lt;/i&gt;&lt;/button&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
  
                    &lt;div id=&quot;con-close-modal&quot; class=&quot;modal fade&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;myModalLabel&quot; aria-hidden=&quot;true&quot; style=&quot;display: none;&quot;&gt;
                      &lt;div class=&quot;modal-dialog&quot;&gt;
                        &lt;div class=&quot;modal-content&quot;&gt;
                          &lt;div class=&quot;modal-header&quot;&gt;
                            &lt;h4 class=&quot;modal-title&quot;&gt;Change &lt;%=users.name%&gt; Role&lt;/h4&gt;
                            &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-hidden=&quot;true&quot;&gt;×&lt;/button&gt;
                          &lt;/div&gt;
                          &lt;form class=&quot;&quot; action=&quot;/changeuserrole&quot; method=&quot;post&quot;&gt;
                            &lt;div class=&quot;modal-body p-4&quot;&gt;
                              &lt;div class=&quot;row&quot;&gt;
                                &lt;div class=&quot;col-md-12&quot;&gt;
                                  &lt;div class=&quot;form-group&quot;&gt;
                                    &lt;label for=&quot;field-1&quot; class=&quot;control-label&quot;&gt;User Role&lt;/label&gt;
                                    &lt;select class=&quot;form-control&quot; name=&quot;role&quot;&gt;
                                      &lt;option&gt;Partner&lt;/option&gt;
                                      &lt;option&gt;Admin&lt;/option&gt;
                                      &lt;option&gt;User&lt;/option&gt;
                                    &lt;/select&gt;
                                  &lt;/div&gt;
                                  &lt;button type=&quot;submit&quot; value=&quot;&lt;%=users._id%&gt;&quot; name=&quot;userroleid&quot; class=&quot;btn btn-primary&quot;&gt;Submit&lt;/button&gt;
                                &lt;/div&gt;
                              &lt;/div&gt;
                            &lt;/div&gt;
                          &lt;/form&gt;
          
                        &lt;/div&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;%});%&gt;
                  &lt;/tbody&gt;
  </code></pre>
  <p>Here is my app.js where I search for the users and pass them to EJS:</p>
  <pre><code>    app.get(&quot;/users&quot;, function(req, res) {
      if (req.isAuthenticated() &amp;&amp; req.user.role === &quot;Admin&quot;) {
  
      User.find({}, function(err, foundUsers) {
        if (err) {
          console.log(err);
        } else {
          res.render(&quot;users&quot;, {
            users: foundUsers,
            name: req.user.name.replace(/ .*/, ''),
            email: req.user.username,
          });
        }
      });
    } else {
      res.redirect(&quot;/login&quot;);
    }
  });
  </code></pre>
  <p>All the &lt;%=users...%&gt; tags work inside the table, but not inside the popup divs. Inside the Popup it just displays the information from the first user in the Database, which is super strange.</p>
  <p>I would be very thankful for any kind of help. Thanks!</p>