DRY up code in active_record.rb