Class: Muck::FriendsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Muck::FriendsController
- Defined in:
- app/controllers/muck/friends_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
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 |
# File 'app/controllers/muck/friends_controller.rb', line 13 def create success = Friend.make_friends(@user, @target) if MuckFriends.configuration.enable_following if success = t('muck.friends.you_are_now_following', :user => @target.display_name) else = t('muck.friends.problem_adding_follow', :user => @target.display_name) end elsif MuckFriends.configuration.enable_friending if success = t('muck.friends.friend_request_sent') else = t('muck.friends.problem_sending_friend_request', :user => @target.display_name) end end respond_to do |format| format.html { render_after_create_html(success, ) } format.js { render_after_create_js(success, ) } format.pjs { render_after_create_js(success, ) } format.json { render :json => { :success => success, :message => , :friend_user => @target } } end end |
#destroy ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/muck/friends_controller.rb', line 65 def destroy success = true # Other user may or may not be a friend. If they weren't then revert_to_follower will return false. # We don't care that the other user wasn't reverted to a follower (since they might not have been a friend) so return true @user.drop_friend(@target) if MuckFriends.configuration.enable_friending = t('muck.friends.removed_friendship', :user => @target.display_name) elsif MuckFriends.configuration.enable_following = t('muck.friends.stopped_following', :user => @target.display_name) end # if MuckFriends.configuration.enable_friending # message = t('muck.friends.removed_friendship_error', :user => @target.display_name) # elsif MuckFriends.configuration.enable_following # message = t('muck.friends.removed_following_error', :user => @target.display_name) # end respond_to do |format| format.html { render_after_destroy_html(success, ) } format.js { render_after_destroy_js(success, ) } format.pjs { render_after_destroy_js(success, ) } format.json { render :json => { :success => success, :message => } } end end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/muck/friends_controller.rb', line 6 def index @user = User.find(params[:user_id]) rescue current_user respond_to do |format| format.html { render :template => 'friends/index' } end end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/muck/friends_controller.rb', line 39 def update if params[:block] success = @user.block_user(@target) elsif params[:unblock] success = @user.unblock_user(@target) end if success if params[:block] = t('muck.friends.blocked', :user => @target.display_name) elsif params[:unblock] = t('muck.friends.unblocked', :user => @target.display_name) end else = t('muck.friends.block_problem', :user => @target.display_name) end respond_to do |format| format.html { render_after_update_html(success, ) } format.js { render_after_update_js(success, ) } format.pjs { render_after_update_js(success, ) } format.json { render :json => { :success => success, :message => , :friend_user => @target } } end end |