friends_controller.rb
1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class FriendsController < MyProfileController
protect 'manage_friends', :profile
def index
if is_cache_expired?(profile.manage_friends_cache_key(params))
@friends = profile.friends.paginate(:per_page => per_page, :page => params[:npage])
end
end
def add
@friend = Person.find(params[:id])
if request.post? && params[:confirmation]
# FIXME this shouldn't be in Person model?
AddFriend.create!(:person => profile, :friend => @friend, :group_for_person => params[:group])
flash[:notice] = _('%s still needs to accept being your friend.') % @friend.name
# FIXME shouldn't redirect to the friend's page?
redirect_to :action => 'index'
end
end
def remove
@friend = profile.friends.find(params[:id])
if request.post? && params[:confirmation]
profile.remove_friend(@friend)
redirect_to :action => 'index'
end
end
protected
class << self
def per_page
10
end
end
def per_page
self.class.per_page
end
end