1

これは、本のテーブルから取得した本の詳細を表示したい私のコードです。

<div class="tab-pane" id="computer">  <!-- Branch Computer -->
        <legend> Computer Science</legend>
            <table class ="table table-hover">
                <thead>
                    <tr>
                        <th> S.No </th>
                        <th> Book Name </th>
                        <th> Year </th>
                        <th> User ID</th>
                        <th> Owner Address</th>
                    </tr>
                </thead>
                <tbody>
                    <% @books.each do |b| %>                                       
                    <tr>
                    <% if b.branch == "Computer Science"%>
                        <td><%= b.id%></td>
                        <td><%= b.book_name%></td>
                        <td><%= b.year%></td>
                        <td><%= b.user_id%></td>
                                                    <!-- For displaying user details -->                             
                        <% @susers.each do |s|%>
                           <% if s.user_id == b.user_id %>
                                <td><%= s.address %></td>
                           <%else%>
                                <td><%"Not found"%></td>
                            <%end%>
                          <%end%>                           

                        <%else%>
                                <td><%"No any book of this branch"%></td>   
                        <%end%>   
                      </tr>                                     
                    <%end%>
                </tbody>    
            </table>    
        </div><!-- End of Computer Branch-->

しかし、ここで出力に何が問題になっているのかわかりませんか?

このように表示されています。各行の長い列に注目してください。編集後、私はこれだけ得ます。

わかりました、これはターミナルで異常なことが起こっています

http://pastie.org/5134510 2 行目に注目してください。 ありがとう

4

1 に答える 1

2

テーブルのフォーマットに関するいくつかの問題を修正するために変更しました。

<div class="tab-pane" id="computer">  <!-- Branch Computer -->
            <legend> Computer Science</legend>
                <table class ="table table-hover">
                    <thead>
                        <tr>
                            <th> S.No </th>
                            <th> Book Name </th>
                            <th> Year </th>
                            <th> User ID</th>
                            <th> Owner Address</th>
                        </tr>
                    </thead>
                    <tbody>
                        <% @books.each do |b| %>
                        <% if b.branch == "Computer Science"%>                                       
                        <tr>
                            <td><%= b.id%></td>
                            <td><%= b.book_name%></td>
                            <td><%= b.year%></td>
                            <td><%= b.user_id%></td>
                                                        <!-- For displaying user details -->                             
                            <% @susers.each do |s|%>
                               <% if s.user_id == b.user_id %>
                                    <td><%= s.address %></td>
                               <%else%>
                                    <td><%"Not found"%></td>
                                <%end%>
                              <%end%>
                            <%end%>   
                          </tr>                                     
                        <%end%>
                    </tbody>    
                </table>    
            </div><!-- End of Computer Branch-->

詳細の問題については、下の結果が右に揃えられている理由がわかりません。私が言うことは、通常はCSSの問題でしたが、なぜそれが私が知らないエントリごとに変わるのですか。

于 2012-10-29T21:21:10.973 に答える