gpt4 book ai didi

ruby-on-rails - 值未存储在 ruby​​ on rails 数组中

转载 作者:太空宇宙 更新时间:2023-11-03 17:52:57 25 4
gpt4 key购买 nike

我初始化数组

k = Array.new

然后类似

@m = Modul.where(:rfp_id => @rfp.id)
i = 0
for ii in @m
k = ii.name.to_s
i = i + 1
end

然后

 k.each do |a|
...
end

但是值没有存储在“k”中,我该怎么做呢?

最佳答案

尝试编写干净的代码,例如:

Modul.where(:rfp_id => @rfp.id).pluck(:name).each do |name|
puts name
end

关于ruby-on-rails - 值未存储在 ruby​​ on rails 数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20696212/

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