I'm writing a Rails app which uses ActiveRecord ORM and a Postgres DB. I've got two attributes which are similar but are separate fields in the database. The assignment and saving of these is kinda complicated so I've put that side of things in their own method. The pseudo-code is as follows
myObject.attr_a = get_the_stuff_from( ref_one ) myObject.attr_b = get_the_stuff_from( ref_two ) myObject.assign_and_save( attr_a ) myObject.assign_and_save( attr_b )
Basically, how can I tell the
assign_and_save method to distinguish between
attr_b so that they get saved into their respective columns in the database. I was thinking of using an additional flag for the method signature, but I think that stunts its re-usability.
What would you recommend?