I'm not asking for code as an answer, rather, a resource or some general guidance.
I have an index page of users. For each user, I check the "friend status" of each user in respect to the current user. As you can imagine, it is a pretty lengthy if and elsif statements in the view page.. which is basically:
<% if current_user %>
<% if current_user.friend_with? profile.user %>
<span class="glyphicon glyphicon-user"></span>
<% elsif current_user.invited_by? profile.user %>
<%= link_to '.', friendship_path(profile.user), :method => "put", :class => "glyphicon glyphicon-check" %>
<% elsif current_user.connected_with? profile.user %>
<span class="glyphicon glyphicon-send" title="Pending approval"></span>
<% elsif current_user == profile.user %>
<span class="glyphicon glyphicon-user"></span>
<% else %>
<%= link_to '.', friendships_path(:user_id => profile), :method => "post", :class => "glyphicon glyphicon-plus" %>
I have this entire logic in the view page, and it is very cumbersome. I would like to clean it up a little and stash it away in the controller (if advisable).
Any guidance would be really appreciated. I imagine having a method to return the type of icon or to render some kind of html code and pass it into the view. Thanks!!