繁体   English   中英

index.html.erb 文件显示带有哈希的数组

[英]index.html.erb file shows array with hash

    Listing articles
    [#<Article id: 1, title: "kiran", text: "kumarafadfadf", created_at: "2018-02-11 12:04:41", updated_at: "2018-02-11 12:04:41">, #<Article id: 2, title: "Ruby ", text: "Rails is awesome framework", created_at: "2018-02-11 12:32:01", updated_at: "2018-02-11 12:32:01">, #<Article id: 3, title: "Santhi", text: "I love you", created_at: "2018-02-11 12:33:26", updated_at: "2018-02-13 04:50:11">, #<Article id: 4, title: "Ruby ", text: "Ruby on rails", created_at: "2018-02-13 04:05:51", updated_at: "2018-02-13 04:05:51">, #<Article id: 5, title: "Rails ", text: "Welcome to Rails", created_at: "2018-02-13 04:10:31", updated_at: "2018-02-13 04:10:31">, #<Article id: 6, title: "adfa", text: "adfadfadf", created_at: "2018-02-13 04:14:14", updated_at: "2018-02-13 04:14:14">, #<Article id: 7, title: "", text: "", created_at: "2018-02-13 04:33:21", updated_at: "2018-02-13 04:33:21">]





    Title   Text
    Rankin  rails5  show    new     edit
    Ruby    Rails is awesome framework  show    new     edit
    ruby    I love you  show    new     edit
    Ruby    Ruby on rails   show    new     edit
    Rails   Welcome to Rails    show    new     edit

index.html.erb

<h1>Listing articles</h1>

<table>
    <tr>
        <th>Title</th>
        <th>Text</th>
    </tr>
    <%= @articles.each do |article| %>
    <tr>

        <td><%= article.title %></td>
        <td><%= article.text %></td>
        <td><%= link_to 'show', article_path(article) %></td>
        <td><%= link_to 'new', new_article_path %></td>
        <td><%= link_to'edit', edit_article_path(article) %></td>

    </tr>
<% end %>
</table>

我只需要显示文章列表。 我怎样才能在这里删除数组。 这里我只显示文章列表,不包括数组。

提前致谢

<%= @articles.each do |article| %>

应该

<% @articles.each do |article| %>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM