>>483 erbを一度も使ったことのない俺がWeb上の解説を読んで適当に回答するよ! > in `display': undefined local variable or method `itemList' for #<MyCGI:0x4030ed9c> (NameError) こんなエラーが出るという質問だと推測。itemListをインスタンス変数あたりに書き変えると動いたよ!
require 'erb' class MyCGI def doItemList im = ItemManager.new @itemList = im.getItemList(10) @erb = ERB.new(DATA.read) display end def display(contentType="text/html") @contentType = contentType @erb.run(binding) end end
class ItemManager def getItemList(n); (1..n).to_a; end end