initialization - Rails - initialize object instance variable -
i have 2 arrays initialise []
in prediction
model's object.
if try:
def initialize @first_estimation = [] @last_estimation = [] end
then many of unit tests fail.
failure/error: assign(:prediction, prediction.new( argumenterror: wrong number of arguments (1 0)
however, if try:
def after_initialize @first_estimation = [] @last_estimation = [] end
then arrays not instantiated.
how can instantiate arrays when object constructed without altering else?
since see parenthesis here prediction.new(
deduce try pass params.
but initialize
doesnt accept => boom
but wait, activerecord model?
if so, have use:
after_initialize :set_arrays def set_arrays @first_estimation = [] @last_estimation = [] end
and maybe use attr_accessor
too, dont know expect
Comments
Post a Comment