0

サポートされているhtlm要素とcss要素を使用してブートストラップスタイルのように見えるように生成および変換したテーブルがあります。

データが存在する場合はテーブルの行を表示するunlessコマンドをコード(Rails 3.2.3)に含めましたが、データが存在しない場合は単一の行(すべての列にまたがる)にメッセージを表示します。

現在は表示されますが、単一の行としては表示されません。

テーブルでspanとcolspanを使用してみましたが、「クリーン」に見えません。

これが空のテーブルです

図1:現在表示されているテーブル(空)

これがデータの表です

図2:1レコードのテーブル

テーブルの生成に使用されるコードは次のとおりです。

<div class="page-header">
  <div class="span10">
    <h1>Listing people</h1>
    <div class="contextual">
      <%= link_to(new_person_path, class: "btn btn-success") do %>
        New Person <i class="icon-plus icon-white"></i>
      <% end %>
    </div>
  </div>

<table class="table table-striped table-bordered table-condensed">
<thead>
  <tr>
    <th></th>
    <th colspan="1">Full Name</th>
    <th colspan="1">DOB</th>
    <th colspan="1">Sex</th>
    <th colspan="1">Address</th>
    <th>Actions</th>
  </tr>
</thead>
<tbody
  <tr>
  <% unless @people.empty? %>
    <% @people.each do |person| %>
      <td><%= person.id %></td>
      <td><%= link_to person.full_name, person %></td>
      <td><%= person.dob %></td>
      <td><%= person.gender_to_s %></td>
      <td>
        <% person.addresses.each do |f| %>
          <%= f.full_address %>
        <% end %>
      </td>
      <td><%#= link_to 'Edit', edit_person_path(person) %> 
        <%= link_to(edit_person_path(person), class: "btn btn-small") do %>
          Edit <i class="icon-edit icon-white"></i>
        <% end %>

        <!-- This currently works but smells -->
        <%= link_to(person, class: "btn btn-small btn-danger", confirm: t_deletion_confirm(person, person.full_name), method: :delete, :title => t('EHM-G.destroy')) do %>
          Destroy <i class="icon-trash icon-white"></i>
        <% end %>
      </td>
    <% end %>
  <tr>
  <% else %>
    <td>Move along nothing to see here<td>
  <% end %>
</tr>
</tbody>                                        
</table>

<br />

<%#= link_to 'New Person', new_person_path %>
<%= link_to(new_person_path, class: "btn btn-success") do %>
  New Person <i class="icon-plus icon-white"></i>
<% end %>
</div>

では、「ここに表示されないものに沿って移動する」(クレジットからGithub)というメッセージを取得して、行の幅全体を「スパン」し、既存の見出しをきれいに表示するにはどうすればよいですか?

ありがとう

PSscaffolding.css.scssがbootstrap-sassをオーバーライドしているように見えるため、ボタンは灰色です。スキャフォールドファイルが削除されると、通常のサービスに戻ります。

4

2 に答える 2

1

diffを使用します。例:http ://sourceforge.net/projects/kdiff3/files/kdiff3/0.9.97/

差分

于 2012-10-02T19:29:45.707 に答える
0

それを理解することはありませんでしたが、再コーディングによって修正されたため、コードのどこかに何か問題がありました(おそらく隠された図、または不正なスペース)。

コードは次のようになります。誰かがそれを引き起こした原因を解明する簡単な方法を知っていますか?

  <div class="page-header">
    <h1>Listing people</h1>

  <div class="contextual">
    <%= link_to(new_person_path, class: "btn btn-success") do %>
      New Person <i class="icon-plus icon-white"></i>
    <% end %>
  </div>
</div>

<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
  <th colspan="1"></th>
  <th colspan="1">Full Name</th>
  <th colspan="1">DOB</th>
  <th colspan="1">Sex</th>
  <th colspan="1">Address</th>
  <th colspan="1">Actions</th>
</tr>
</thead>
<tbody>
  <% unless @people.empty? %>
    <% @people.each do |person| %>
      <tr>
        <td></td>
        <td><%= link_to person.full_name, person %></td>
        <td><%= person.dob %></td>
        <td><%= person.gender_to_s %></td>
        <td>
          <% person.addresses.each do |address| %>
            <%= address.full_address %>
          <% end %>
        </td>          
        <td>
          <%#= link_to 'Edit', edit_person_path(person) %> 
          <%= link_to(edit_person_path(person), class: "btn btn-small") do %>
            Edit <i class="icon-edit icon-white"></i>
          <% end %>

          <!-- This currently works but smells -->
          <%= link_to(person, class: "btn btn-small btn-danger", confirm: t_deletion_confirm(person, person.full_name), method: :delete, :title => t('EHM-G.destroy')) do %>
            Destroy <i class="icon-trash icon-white"></i>
          <% end %>

          <%#= icon_delete_link_to(person, people_path, person.full_name) %>
        </td>
      </tr>
    <% end %>
  <% else %>
    <tr>
      <td colspan="0">Nothing to see here move along please</td>
    </tr>
  <% end %>
  </tbody>
</table>
</div>

ここに画像の説明を入力してください

昨日は見えませんでしたが、「木の木症候群!」これが他の誰かの助けになることを願っています。

私自身の学習のために、それを引き起こした原因を理解するための最良の方法は何ですか?私にはコードはまだ同じように見えます

于 2012-04-28T12:13:20.273 に答える