2016-06-21 36 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 + /”注释掉了这些行,如下所示:'