Ascent

User.pronoun() is a Time Saver

Usability is all about the little things. Small changes in how your copy reads can have big effects in how your users react to things.

This is one reason why designers love to use gender-specific language in copy. For example: "Hey Ben, [first name] just sent you a gift! You should thank [him/her]". As any dev knows, user.first_name is easy to put into that statement. Him/Her, on the other hand, just annoys me. Each time i need to implement it, i have write another if statement to display those words. Until today.

After being consistently annoyed with what felt like repeated code, i have come up with a frustratingly simple solution. Frustrating insofar as i don't know why it took me so long to write this function in the first place. But for those of you who share in my struggle, i present the light at the end of the tunnel:

def pronoun( type=:subject )  
    pronoun = ''

    case type.to_sym
    when :subject
        pronoun = 'they'
        if sex == 'male'   then  pronoun = 'he'   end
        if sex == 'female' then  pronoun = 'she'  end
    when :object
        pronoun = 'them'
        if sex == 'male'   then  pronoun = 'him'  end
        if sex == 'female' then  pronoun = 'her'  end
    when :possessive
        pronoun = 'their'
        if sex == 'male'   then  pronoun = 'his'   end
        if sex == 'female' then  pronoun = 'hers'  end
    when :reflexive
        pronoun = 'themselves'
        if sex == 'male'   then  pronoun = 'himself'  end
        if sex == 'female' then  pronoun = 'herself'  end
    end

    pronoun
end  

Some will notice my "default" cases are plural. This is not by accident. The labels being used in gender identity have changed a lot in recent years. This is great for expression and identity, but tricky for code. I've had many conversations about this since i work at a dating site.

What i continue to hear from sources far more knowledgable than i is that addressing non-binary genders in the plural is emerging as the correct standard. Easy enough! By defaulting to the plural and diverting only on the specific cases of male and female, we make no assumptions about the selected gender options moving forward.

So drop this into your server and/or client user models (i have it in both at MeetMindful). Once you have a simple way to refer to users in a gender-appropriate way, you are one step closer to implementing proper designs without feeling like your code quality is being compromised.

tl;dr: Gender appropriate pronouns are a great way to personalize your copy. user.pronoun() is simple function that makes it easy to implement.

Want more tips on Ruby, teams and development? Join the thousands already here.
Author image
Written by Ben
Denver, CO https://benroux.me
VP of Engineering at MeetMindful. I create products, websites and consult for teams on their process and product. Want to chat? Send me an email.