Skip to content

Commit

Permalink
More efficient My Groups. Close #124.
Browse files Browse the repository at this point in the history
  • Loading branch information
bamnet committed Jul 13, 2012
1 parent ff0869e commit bfff126
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class GroupsController < ApplicationController
# GET /groups
# GET /groups.xml
def index
@groups = Group.all
@my_groups = current_user.nil? ? [] : current_user.groups
@groups = Group.all - @my_groups
auth!

respond_to do |format|
Expand Down
5 changes: 3 additions & 2 deletions app/views/groups/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
<% end %>
</ul>
<% end %>
<% if !@groups.empty? %>
<% other_groups = @groups - @my_groups %>
<% if !other_groups.empty? %>
<div class="subnav clearfix">
<h4>Other Groups</h4>
</div>
<ul class="list-stacked">
<% @groups.each do |group| %>
<% other_groups.each do |group| %>
<li>
<h3>
<%= link_to group, :class => "link-hl" do %>
Expand Down
2 changes: 1 addition & 1 deletion test/functional/groups_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ def setup
get :index
assert assigns(:my_groups)
assert_equal assigns(:my_groups).count, 2
assert_equal assigns(:groups).count, 0
assert_equal assigns(:groups).count, 2
end
end

0 comments on commit bfff126

Please sign in to comment.