GitHub PullRequestReviewCommentEvent at 2014-05-27 02:47:01
Repository: WebsiteOne
Actor: johnnymo87
Payload: {"comment":{"url":"https://api.github.com/repos/AgileVentures/WebsiteOne/pulls/comments/13060679","id":13060679,"diff_hunk":"@@ -25,14 +25,13 @@ def hire_me_contact_form\n \n   def show\n     @user = User.friendly.find(params[:id])\n-    @skills = @user.skill_list\n-    @users_projects = @user.following_by_type('Project')\n \n     if !@user.display_profile  && (current_user.try(&:id) != @user.id)\n       flash[:notice] = 'User has set his profile to private'\n       redirect_to root_path\n-    else\n-      @youtube_videos  = Youtube.user_videos(@user) if @user\n+    elsif @user\n+      @youtube_videos  = Youtube.user_videos(@user)\n+      @youtube_videos = @youtube_videos.first(5) if @youtube_videos\n     end\n   end\n end","path":"app/controllers/users_controller.rb","position":17,"original_position":17,"commit_id":"6ce00317e6015eadc49f15c6db2140cbe951d931","original_commit_id":"6ce00317e6015eadc49f15c6db2140cbe951d931","user":{"login":"johnnymo87","id":3466499,"avatar_url":"https://avatars.githubusercontent.com/u/3466499?","gravatar_id":"e8e83ee35acbd3e5858d88bc85f53f47","url":"https://api.github.com/users/johnnymo87","html_url":"https://github.com/johnnymo87","followers_url":"https://api.github.com/users/johnnymo87/followers","following_url":"https://api.github.com/users/johnnymo87/following{/other_user}","gists_url":"https://api.github.com/users/johnnymo87/gists{/gist_id}","starred_url":"https://api.github.com/users/johnnymo87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnnymo87/subscriptions","organizations_url":"https://api.github.com/users/johnnymo87/orgs","repos_url":"https://api.github.com/users/johnnymo87/repos","events_url":"https://api.github.com/users/johnnymo87/events{/privacy}","received_events_url":"https://api.github.com/users/johnnymo87/received_events","type":"User","site_admin":false},"body":"What about something more like this?\r\n\r\n    class UsersController < ApplicationController\r\n      include Youtube\r\n    \r\n      # other methods elided\r\n    \r\n      def show\r\n        @user = User.friendly.find(params[:id])\r\n        @user.extend Foo\r\n    \r\n        @user.check_bar_about(current_user, failure: ->(){\r\n          flash[:notice] = 'User has set his profile to private'\r\n          redirect_to root_path\r\n        })\r\n        @youtube_videos = @user.fizz_buzz_from(Youtube)\r\n      end\r\n    end\r\n    \r\n    module Foo\r\n    \r\n      def check_bar_about(current_user, failure:raise)\r\n        if display_profile  && (current_user.try(&:id) != id)\r\n          failure.call\r\n        end\r\n      end\r\n    \r\n      def fizz_buzz_from(Youtube)\r\n        Youtube.user_videos(self).first(5)\r\n        # this obviously wouldn't work unless we refactor Youtube#user_videos to\r\n        # handle nils more gracefully.\r\n      end\r\n    end\r\n","created_at":"2014-05-27T02:47:01Z","updated_at":"2014-05-27T02:47:01Z","html_url":"https://github.com/AgileVentures/WebsiteOne/pull/417#discussion_r13060679","pull_request_url":"https://api.github.com/repos/AgileVentures/WebsiteOne/pulls/417","_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/WebsiteOne/pulls/comments/13060679"},"html":{"href":"https://github.com/AgileVentures/WebsiteOne/pull/417#discussion_r13060679"},"pull_request":{"href":"https://api.github.com/repos/AgileVentures/WebsiteOne/pulls/417"}}}}