【问题标题】:CSV upload display glitch Rails 6CSV上传显示故障Rails 6
【发布时间】:2021-02-08 02:34:50
【问题描述】:

所以我正确设置了控制器和模型区域中的所有内容,但在视图方面遇到了一些问题。出于某种原因,它正确显示了 1-3 秒,但随着更多元素加载并弹出到我只能描述为终端视图或只是原始数组视图而不是 html/css 它应该进去吧。这是我的代码:

<table>
<thead>
    <tr>
    <th>Company Name</th>
    <th>Country</th>
    <th>Region</th>
    <th>Description</th>
    <th>Last Funding</th>
    <th>Total Funding (USD)</th>
    </tr>
</thead>
<tbody>
    <%= @data.each do |datum| %>
    <tr>
    <th><%= datum.company_name %></th>
    <th><%= datum.country_code %></th>
    <th><%= datum.region_name %></th>
    <th><%= datum.description %></th>
    <th><%= datum.last_funding_on %></th>
    <th>$<%= datum.total_funding_usd %></th>
    </tr>
    <% end %>
</tbody>

这是它在浏览器中的样子:

[#, #

【问题讨论】:

    标签: ruby-on-rails ruby csv activerecord file-upload


    【解决方案1】:

    只需替换这一行

    <%= @data.each do |datum| %>
    

    <% @data.each do |datum| %>
    

    因为您不想输出(&lt;%each 方法调用的返回值。您只想输出 (&lt;%=) 的属性。

    【讨论】:

    • 达到最高 derp 等级...恭喜我>.
    猜你喜欢
    • 2018-11-14
    • 2022-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-25
    • 2019-12-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多