在我的酒店型号上添加导出到CSV按钮时出现以下错误。
Missing template hotels/index, application/index with {:locale=>[:en], :formats=>[:csv], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. Searched in:
* "/Users/kallan1/Desktop/GSW-CRM/app/views"
* "/Users/kallan1/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/devise-3.4.1/app/views"
提前致谢,如果您需要更多信息,请告知我们
答案 0 :(得分:0)
Rails希望找到hotels/index, application/index
(控制器)操作的视图(例如html文件)。您是否定义了相应的视图文件?
编辑似乎是控制器响应中的问题。这是大约您在控制器的index
定义中应具有的内容:
respond_to do |format|
format.html
format.csv { send_data @users.to_csv, filename: "example.csv" } # fill these with appropriate names
end