I think this could be much easier to implement with a helper in app/helpers/people_helper.rb like I did here: https://github.com/diaspora/diaspora/pull/4374/files