阅读背景:

Ruby:`gsub':无法将nil转换为String(TypeError)

来源:互联网 
def export_no_sdesc(item_no = " ", make = " ", model = " ", list_price = " ", long_desc = " ", global_image_path = " ")
final_image_path = global_image_path + item_no + ".jpg"
final_thumbs_path = global_image_path + "thumbs/" + item_no + ".jpg"
Dir.glob("body.tmp") do |filename|
    body = file_as_string(filename)
    body = body.gsub("item_no", item_no).gsub("image_path", final_image_path).gsub("image_thumb", final_thumbs_path)
    body = body.gsub("part_make", make).gsub("part_model", model).gsub("long_desc", long_desc).gsub("list_price", list_price)
    File.open('page_export.html', 'a') do |x|
        x.puts body
        x.close
    end
  end
end
def export_no_sdesc(item_no = " ", make = " ", 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: