I have a strange error, I do not understand why it gets as it gets.
This code:
<table style="width: 100%;">
<thead>
<tr>
<th>Roll</th>
<th>Email</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<% @users.each do |u| %>
<tr>
<td>
Foo
<% if u.roll_id == 1 %>
Admin
<% else %>
User
<% end if %>
</td>
<td><%= link_to u.email, user_path(u.id) %></td>
<td><%= u.first_name %></td>
<td><%= u.last_name %></td>
<td>
<%= link_to "Edit", user_path(u.id), :class =>"button radius small blue" %>
<%= link_to "Delete", user_path(u.id), confirm: "Are you sure??", method: :delete, :class =>"button radius small red" %>
</td>
</tr>
<% end %>
</tbody>
</table>
The problem is that admin or select the user are printed in the wrong cell, it prints the email cell and not in the correct cell. The word “Foo” is printed where it should be, but not that which is within if-statement
The generated HTML code looks like this:
<table style="width: 100%;">
<thead>
<tr>
<th>Roll</th>
<th>Email</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Foo
</td>
<td> User
<a href="/users/1">mail</a></td>
<td>Banana</td>
<td>Apple</td>
<td>
<a href="/users/1" class="button radius small blue">Edit</a>
<a href="/users/1" class="button radius small red" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Delete</a>
</td>
</tr>
<tr>
<td>
Foo
</td>
<td> Admin
<a href="/users/2">mail</a></td>
<td>firstname</td>
<td>lastname</td>
<td>
<a href="/users/2" class="button radius small blue">Edit</a>
<a href="/users/2" class="button radius small red" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Delete</a>
</td>
</tr>
<tr>
<td>
Foo
</td>
<td> Admin
<a href="/users/3">mail</a></td>
<td>Tord</td>
<td>Bob</td>
<td>
<a href="/users/3" class="button radius small blue">Edit</a>
<a href="/users/3" class="button radius small red" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Delete</a>
</td>
</tr>
</tbody>
Just a quick idea, but your
end ifshould readend. Does that help?