followers_controller.rb
1.39 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
class FollowersController < MyProfileController
before_filter :only_for_person, :only => :index
def index
@followed_people = current_person.followed_profiles.order(:type).paginate(:per_page => 15, :page => params[:npage])
end
def set_category_modal
categories = Circle.where(:person => current_person).map(&:name)
profile = Profile.find(params[:followed_profile_id])
render :partial => 'blocks/profile_info_actions/follow_categories', :locals => { :categories => categories, :profile => profile }
end
#TODO fix
def update_category
params["followed_profile_id"] ||= profile.id
#TODO FIX profile type. REMOVE THE GAMBIRA
if params[:category_name]
category = Circle.find_or_create_by(:name => params[:category_name], :person => current_person, :profile_type => 'Person')
if category.id.nil?
category = Circle.find_or_create_by(:name => params[:category_name], :person => current_person, :profile_type => 'Community')
end
follower = ProfileFollower.find_or_create_by(circle: category, profile: Profile.find_by(:id => params[:followed_profile_id]))
end
redirect_url = params["redirect_to"] ? params["redirect_to"] : url_for(:controller => "followers", :action => "index", :profile => current_person.identifier)
redirect_to redirect_url
end
protected
def only_for_person
render_not_found unless profile.person?
end
end