refactor duplicated code into field_attributes.rb