2012-02-29 8 views
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> 

問題は、その管理者であるか、またはユーザーを選択し、それが正しいセルに電子メールのセルを印刷していない、間違ったセルに印刷されています。単語「フー」は、それがあるべき場所に印刷ではなく、その生成されたHTMLコードは次のようになりますif文

内にあるされています

<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> 

答えて

0

だけで簡単にアイデアが、 end ifendとなります。それは役に立ちますか?

+0

ありがとうございました。 私はRailsの操作に慣れていないので、かなり間違いがありました。 –