【问题标题】:Why it show a missing template error in my code为什么它在我的代码中显示缺少模板错误
【发布时间】:2016-07-31 02:22:24
【问题描述】:

控制器方法

def export
  @customers =Customer.all

  flash[:success] = "Script ran successfully"
end

我正在尝试将所有客户导出到 csv 文件中,但我收到了缺少模板的错误。为什么?在我的视图文件夹中,我有一个按钮。

<p><%= button_to 'export Import', scripts_export_data_path %></p>

我想将客户数据导出到上面的按钮中。

【问题讨论】:

标签: ruby-on-rails ruby csv export-to-csv


【解决方案1】:

您需要在您拥有 Flash 消息的行之后呈现或重定向到要显示的页面。 Flash 消息显示在下一页加载任何可能的内容。

def export
@customers =Customer.all

flash[:success] = "Script ran successfully"

redirect_to 'page/template' or.... render 'page/template'

end

【讨论】:

    【解决方案2】:

    试试这个例子,

    Exporting CSV

    【讨论】:

      猜你喜欢
      • 2010-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-14
      • 2019-05-05
      • 2022-01-06
      • 2022-01-08
      相关资源
      最近更新 更多