0
我有一個奇怪的錯誤,我不明白爲什麼它得到它。表奇怪的錯誤 - Ruby on Rails
此代碼:
<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>
的問題是,管理或選擇用戶打印在錯誤的小區,它打印電子郵件小區和不正確的細胞。 「富」這個詞是印在它應該是,但不是說這是if語句
生成的HTML代碼如下所示內:
<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="https://stackoverflow.com/users/1">mail</a></td>
<td>Banana</td>
<td>Apple</td>
<td>
<a href="https://stackoverflow.com/users/1" class="button radius small blue">Edit</a>
<a href="https://stackoverflow.com/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="https://stackoverflow.com/users/2">mail</a></td>
<td>firstname</td>
<td>lastname</td>
<td>
<a href="https://stackoverflow.com/users/2" class="button radius small blue">Edit</a>
<a href="https://stackoverflow.com/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="https://stackoverflow.com/users/3">mail</a></td>
<td>Tord</td>
<td>Bob</td>
<td>
<a href="https://stackoverflow.com/users/3" class="button radius small blue">Edit</a>
<a href="https://stackoverflow.com/users/3" class="button radius small red" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Delete</a>
</td>
</tr>
</tbody>
非常感謝。 我不習慣使用Rails,所以很明顯的錯誤。 – 2012-02-29 15:32:52