gpt4 book ai didi

mysql - main :Object (NameError) 的未定义局部变量或方法 `category'

转载 作者:行者123 更新时间:2023-11-29 22:39:11 25 4
gpt4 key购买 nike

require 'csv'
load 'dbconnection.rb'
require 'activerecord'

class Definition<ActiveRecord::Base

end
csv_definition = File.read('C:/definition.csv')
spy_definition = CSV.parse(csv_definition, :headers => false)
spy_definition.each do |row|
Definition.create!(

:id => row[id],
:category => row[category],
:name => row[name],
:dangerlevel => [dangerlevel],
:description => [description]
)

end

我收到如下错误:

datainsertion.rb:26: warning: Object#id will be deprecated; use Object#object_id
datainsertion.rb:27: undefined local variable or method `category' for main:Object (NameError)
from datainsertion.rb:24:in `each'
from datainsertion.rb:24
>Exit code: 1

我需要将该 csv 文件加载到数据库中,但我收到此错误..,帮我解决这个问题。,

最佳答案

错误确实是您所需要的。您有一个尚 undefined variable 类别。尝试“类别”。

关于mysql - main :Object (NameError) 的未定义局部变量或方法 `category',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29430773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com