我有以下代码并收到"undefined method each' for nil:NilClass"
@loan_ids = params[:moredata].split(",").map { |s| s.to_i }
@loans_ids.each do |number|
puts number
end
答案 0 :(得分:1)
其@loan_ids.each
而非@loans_ids.each
答案 1 :(得分:1)
@loan_ids=params[:moredata].split(",").map{|s| s.to_i }
@loan_ids.each do |number|
puts number
end
你拼错了它
答案 2 :(得分:0)
@loan_ids.each
而不是@loans_ids.each
。当没有这样定义时,你有一个复数“贷款”。