Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

groups show and index

  • Loading branch information...
commit 699c035fe9f6bd0d7663c1a3876dffb25853d889 1 parent f356ca6
mcansky authored
View
2  app/controllers/groups_controller.rb
@@ -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
View
7 app/models/group.rb
@@ -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
View
6 app/views/groups/show.haml
@@ -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)
View
2  app/views/posts/_posts_short.haml
@@ -1,4 +1,4 @@
%div.posts
- posts.each do |post|
%div.bookmark
- = render "short_post", :post => post
+ = render "posts/short_post", :post => post
Please sign in to comment.
Something went wrong with that request. Please try again.