gpt4 book ai didi

ruby-on-rails - 迭代 9 次,我认为我有语法错误

转载 作者:数据小太阳 更新时间:2023-10-29 08:44:40 25 4
gpt4 key购买 nike

 @numbers = [1,2,3,4,5,6,7,8,9]

@numbers.each do |n|

if @order.card_type"n" != "none"
notes += "\n\nCard 1: " + @order.card_type1 + "\nPaper Weight: " + @order.paper_weight1 + "\nQuantity: " + @order.quantity1 + "\nInk Color #1: " + @order.ink_color11 + "\nInk Color #2: " + @order.ink_color12 + "\nWording: " + @order.wording1 + "\nReturn Address Printing: " + @order.return_address1 + "\nGuest Address Printing: " + @order.guest_address1.to_s + "\nEnvelope Liners: " + @order.envelope_liners1
end

end

我不确定我做错了什么,但我需要在我的 Controller 中用 1-9 替换“n”。我想不出正确的方法来做到这一点。

最佳答案

只需使用 [] 符号和字符串操作访问它:

(1..9).each do |n|              

if @order["card_type#{n}"] != "none"
# ...
end

end

否则,您还可以:

@order.send("card_type#{n}")

关于ruby-on-rails - 迭代 9 次,我认为我有语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33246494/

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