缺少模板调整/索引,带有{:locale => [:en] 、: formats => [:csv] 、: variants => [] 、: handlers => [:raw,:erb, :html,:builder,:ruby,:coffee,:jbuilder]}。在以下位置搜索:
尝试安全创建模型的csv时遇到此错误,我正在寻求帮助来解决这个难题。我不是开发人员,我只是为个人工作文件制作了Rails应用程序。
我的模型tuning.rb
class Tuning < ApplicationRecord
has_many :invoices, dependent: :destroy
has_many :pianos
has_many :contacteds
has_many :interests
has_many :expenses, through: :pianos
accepts_nested_attributes_for :pianos
accepts_nested_attributes_for :invoices
accepts_nested_attributes_for :contacteds
accepts_nested_attributes_for :interests
validates :Client, presence: true
validates :Tel, presence: true
validates :Address, presence: true
geocoded_by :Address
after_validation :geocode
def start_time
self.scheduled_date.start
end
def index
@tunings = Tuning.all
end
def self.to_csv
CSV.generate do |csv|
csv << column_names
all.each do |client|
csv << client.attributes.values_at(*column_names)
end
end
end
end
my controller:
def index
@tunings = Tuning.all.order('scheduled_date ASC')
respond_to do |format|
format.html
format.csv { render text: @tunings.to_csv }
@invoices = Invoice.all
end
add_breadcrumb "Home", :root_path
add_breadcrumb "All Tunings"
end
非常感谢您的投入。谢谢