我有一个尽可能简单的Ruby on rails类:
class ProductProperty < ApplicationRecord
def initialize
puts 'hello world'
end
end
但是,当我简单地try 实例化它时,我得到一个ArgumentError:
[1] pry(main)> ProductProperty.new
ArgumentError: wrong number of arguments (given 1, expected 0)
我不清楚为什么它认为我在("given 1
")中传递参数.为了能够编写不带参数的initialize
方法,我还需要做一些其他的事情吗?