%a{href: user_path(user)}
  %li
    =image_tag Gravatar.new(user.email).image_url(:size => 40), class: "avatar"
    %span= format_user_name(user)

= link_to user_path(user) do
  %li
    =image_tag Gravatar.new(user.email).image_url(:size => 40), class: "avatar"
    %span= format_user_name(user)

Use link helper instead of raw a tag
Use link helper instead of raw a tag
