2016-06-21 37 views
0

我正在關注如何創建一個帶有註釋和標籤的Ruby-on-Rails博客網站tutorial,並且已將我的工作放到https://github.com/khpeek/jumpstart-blogger/上。刪除表中的列

本教程的最後部分涉及允許作者創建用戶名和密碼。其中一個網頁是從「巫術」寶石作者的默認列表:

enter image description here

正如你所看到的,也有與「密碼」和「確認密碼」,我想空白列喜歡刪除。

該網頁的外觀是由app/views/authors/index.html.erb,其內容

<p id="notice"><%= notice %></p> 

<h1>Listing Authors</h1> 

<table> 
    <thead> 
    <tr> 
     <th>Username</th> 
     <th>Email</th> 
     <th>Password</th> 
     <th>Password confirmation</th> 
     <th colspan="3"></th> 
    </tr> 
    </thead> 

    <tbody> 
    <% @authors.each do |author| %> 
     <tr> 
     <td><%= author.username %></td> 
     <td><%= author.email %></td> 
     <td><%= author.password %></td> 
     <td><%= author.password_confirmation %></td> 
     <td><%= link_to 'Show', author %></td> 
     <td><%= link_to 'Edit', edit_author_path(author) %></td> 
     <td><%= link_to 'Destroy', author, method: :delete, data: { confirm: 'Are you sure?' } %></td> 
     </tr> 
    <% end %> 
    </tbody> 
</table> 

<br> 

<%= link_to 'New Author', new_author_path %> 

我的想法是,以行註釋掉

<th>Password</th> 
    <th>Password confirmation</th> 

<td><%= author.password %></td> 
    <td><%= author.password_confirmation %></td> 

但是,如果我統治做到這一點,一些文本被放置在主邊界框之外:

enter image description here

是否有可能從正在發生的事情錯在這裏,代碼的這個有限的部分告訴?

+0

你是怎麼評論的代碼,你可以發佈您的代碼? – Kld

回答

1

發生這種情況是因爲您沒有「告訴」您的表格填滿整個寬度的樣式。

嘗試添加以下樣式:

<style> 
    table { width: 100%; } 
</style> 
+0

我在'app/assets/stylesheets/styles.css.css'中增加了'table {width:1000%}',但框外的文字仍然存在(儘管框內的文字水平分佈更好)。我在Atom編輯器中使用「Cntrl + /」註釋掉了這些行,如下所示:'