【发布时间】:2012-03-18 17:54:03
【问题描述】:
我有点 Ruby,菜鸟,有一些基本的东西我没有得到。我有这样的事情:
def my_method
attr1 = 'new 1 value'
attr2 = 'new 2 value'
puts "#{attr1} - #{attr2}"
puts "Should be same? #{to_s}"
end
def to_s
"#{attr1} - #{attr2}"
end
当我调用 my_method 时,我得到:
new 1 value - new 2 value
Should be same? old 1 value - old 2 value
嗯?
【问题讨论】:
标签: ruby-on-rails-3 activerecord ruby-1.9