Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Commit

Permalink
groups show and index
Browse files Browse the repository at this point in the history
  • Loading branch information
mcansky committed Feb 7, 2011
1 parent f356ca6 commit 699c035
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def index

def show
@group = Group.find(params[:id])
bookmarks = Bookmark.find(:all, :conditions => ['private = 0 AND user_id in (?)', @group.users_id])
@bookmarks = bookmarks.paginate(:page => params[:page])
end

def new
Expand Down
7 changes: 7 additions & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ class Group < ActiveRecord::Base
validates_uniqueness_of :name, :case_sensitive => true
has_and_belongs_to_many :users
belongs_to :owner, :class_name => "User", :foreign_key => "owner_id"
has_many :bookmarks, :through => :users, :conditions => ["private = 0"]

def users_id
ids = Array.new
users.each { |u| ids << u.id }
return ids
end
end
6 changes: 5 additions & 1 deletion app/views/groups/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
%p= @group.desc

%h3 Members
= render "groups/members", :group => @group

= render "groups/members", :group => @group
%h3 Bookmarks
= render "posts/posts_short", :posts => @bookmarks
.pagination
= will_paginate(@bookmarks)
2 changes: 1 addition & 1 deletion app/views/posts/_posts_short.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%div.posts
- posts.each do |post|
%div.bookmark
= render "short_post", :post => post
= render "posts/short_post", :post => post

0 comments on commit 699c035

Please sign in to comment.