Currently, to set some default values, but also keep any values that the
user specifies to new, i’m doing this:
def initialize(*params)
defaults = {:resources => true,
:lessons => true,
:courses => true,
:sort_by => “name”,
:term => “”,
:kinds => [“0”],
:fields => [“0”],
:subject_families => [“0”],
:subject_family_members => [“0”]
}
params[0] = defaults.merge(params[0] || {})
super(*params)
end
It works but seems a bit dirty. Is there a nicer way? I know that the
after_intialize callback is called after a record is retrieved from the
db as well (i never understood the logic behind this) so i avoided
using that.