Mass assignment to an AR that would call assignment methods


I have an AR instance foo that recently got an assignment method
#bar=. Before this addition I could use mass-assignment for foo with:[:foo])


foo.attributes = params[:foo]

But appearantly assignment methods like #bar= don’t get called with
the 2 examples above. I have to:

foo =
params[:foo].each do |key, val|
rec[key] = val

and something very similar for updating. Is this the best way, or is
there some convenient builtin mass-assignment method which does call
the appropriate assigment method for each attribute?