好的,我是一個新手。我知道這個錯誤發生,因爲我沒有正確理解如何調用方法。那麼你能幫我理解這裏發生了什麼問題嗎?Ruby NoMethodError
ThingController中的NoMethodError#index 未定義的方法`已初始化?'對於事情::後端:類
從ThingController.rb的示數節:
class ThingController
def init_things
Backend.init_things unless Backend.initialized?
end
t = ThingController.new
t.init_things
end
內Backend.rb
class Backend
# checks if the things hash is initialized
def initialized?
@initialized ||= false
end
# loads things
def init_things
puts "I've loaded a bunch of files into a hash"
@initialized = true
end
end
我沒有正確調用方法,我無法找到對互聯網上的這個錯誤有任何明確的解釋。請幫忙。
感謝
謝謝大家。你已經回答了我的問題,並幫助我解決了這個問題。 Railstips看起來也是一個非常有用的博客。 – Tsagadai 2011-04-21 05:01:15