Skip to content

Instantly share code, notes, and snippets.

@Gregg
Created January 21, 2011 16:19
Show Gist options
  • Save Gregg/789910 to your computer and use it in GitHub Desktop.
Save Gregg/789910 to your computer and use it in GitHub Desktop.
<% current_user.who_to_follow.limit(5).each do |f| %>
<li><%= f.name %> - <%= link_to "Follow", follow_user_path(f) %></li>
<% end %>
# It's generally bad practice to have any code that queries your db right there in the view. You want to do the queries in your controller if at all possible.
<% @who_to_follow.each do |f| %>
<li><%= f.name %> - <%= link_to "Follow", follow_user_path(f) %></li>
<% end %>
class TweetsController < ApplicationController
def index
@who_to_follow = current_user.who_to_follow.limit(5)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment