{"action":"opened","number":131,"pull_request":{"url":"https://api.github.com/repos/briankung/projectcredo/pulls/131","id":90486496,"html_url":"https://github.com/briankung/projectcredo/pull/131","diff_url":"https://github.com/briankung/projectcredo/pull/131.diff","patch_url":"https://github.com/briankung/projectcredo/pull/131.patch","issue_url":"https://api.github.com/repos/briankung/projectcredo/issues/131","number":131,"state":"open","locked":false,"title":"Adds pry-rails for debugging","user":{"login":"briankung","id":2836167,"avatar_url":"https://avatars.githubusercontent.com/u/2836167?v=3","gravatar_id":"","url":"https://api.github.com/users/briankung","html_url":"https://github.com/briankung","followers_url":"https://api.github.com/users/briankung/followers","following_url":"https://api.github.com/users/briankung/following{/other_user}","gists_url":"https://api.github.com/users/briankung/gists{/gist_id}","starred_url":"https://api.github.com/users/briankung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briankung/subscriptions","organizations_url":"https://api.github.com/users/briankung/orgs","repos_url":"https://api.github.com/users/briankung/repos","events_url":"https://api.github.com/users/briankung/events{/privacy}","received_events_url":"https://api.github.com/users/briankung/received_events","type":"User","site_admin":false},"body":"**Problem:** None, really, I just miss pry. And while the web console is alright, pry is way better.\r\n\r\n**Solution:** Add `pry-rails`\r\n\r\n**Complications:** None?\r\n\r\n**Usage:** \r\n\r\nhttps://gist.github.com/briankung/ebfb567d149209d2d308576a6a34e5d8 (copied below)\r\n\r\n____________\r\n\r\nFirst, add pry-rails to your Gemfile:  \r\nhttps://github.com/rweng/pry-rails\r\n\r\n```ruby\r\ngem 'pry-rails', group: :development\r\n```\r\n\r\nThen you'll want to rebuild your Docker container to install the gems\r\n\r\n```sh\r\ndocker-compose build\r\n```\r\n\r\nYou should now be able to add a break point anywhere in your code\r\n\r\n```ruby\r\nbinding.pry\r\n```\r\n\r\nThe problem is that Docker just kind of ignores it and moves on. In order to actually halt execution and use pry as normal, you have to these options to docker-compose.yml:\r\n\r\n```yaml\r\napp:\r\n  tty: true\r\n  stdin_open: true\r\n```\r\n\r\nSource: http://stackoverflow.com/a/37264588/1042144\r\n\r\nThe next time `binding.pry` is executed, the process should halt and display an IRB-like console on the rails server screen. But you still can't use it directly. You have to attach a terminal to the docker container.\r\n\r\nIn order to attach to a docker container, you need to know what its ID is. Use `docker ps` to get a list of the running containers and their ids.\r\n\r\n```sh\r\ndocker ps\r\n```\r\n\r\nSource: https://www.liquidweb.com/kb/how-to-list-and-attach-to-docker-containers/\r\n\r\nThen you can use the numeric ID to attach to the docker instance:\r\n\r\n```sh\r\ndocker attach 75cde1ab8133\r\n```\r\n\r\nIt may not immediately show a rails console, but start typing and it should appear. If you keep this attached, it should show the rails console prompt the next time you hit the pry breakpoint.\r\n\r\nNeat things you should try with pry:\r\n\r\n```ruby\r\nshow-routes\r\nshow-models\r\nshow-source edit  # If you're in a controller, for instance\r\n\r\ncd                # Navigate up or down class hierarchies. try `cd BasicObject`\r\nls                # Check out what's inside of a class - variables, etc.\r\n```\r\n\r\nAnd of course you can access local variables just by typing their names.\r\n\r\n```ruby\r\nparams\r\n#=> <ActionController::Parameters {\"controller\"=>\"lists\", \"action\"=>\"index\"} permitted: false>\r\n```\r\n\r\nTo end your pry-rails session, you can type exit as you would exit any irb instance.\r\n\r\n```ruby\r\nexit\r\n```\r\n\r\nHowever, this does not detach the terminal from the docker container. This can be useful to continue debugging.\r\n\r\nAdditionally, I had two terminals open, one to review the server log and one to attach to my container to use pry-rails, but docker will timeout the server log while the attached terminal  continues to run the rails server process. I'm okay with that - I can just leave the terminal attached. However, if you want to detach from the container without ending the process, you need to press ctrl-p + ctrl-q.\r\n\r\nSource: http://stackoverflow.com/a/19689048/1042144\r\n\r\n","created_at":"2016-10-22T16:06:05Z","updated_at":"2016-10-22T16:06:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a660fcd34a31ce20e1448562f6ba9f478fa97fc5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/briankung/projectcredo/pulls/131/commits","review_comments_url":"https://api.github.com/repos/briankung/projectcredo/pulls/131/comments","review_comment_url":"https://api.github.com/repos/briankung/projectcredo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/briankung/projectcredo/issues/131/comments","statuses_url":"https://api.github.com/repos/briankung/projectcredo/statuses/d4eb4c7c3183b0e57f1e01ea6318ae28cdd820ae","head":{"label":"briankung:pryRails","ref":"pryRails","sha":"d4eb4c7c3183b0e57f1e01ea6318ae28cdd820ae","user":{"login":"briankung","id":2836167,"avatar_url":"https://avatars.githubusercontent.com/u/2836167?v=3","gravatar_id":"","url":"https://api.github.com/users/briankung","html_url":"https://github.com/briankung","followers_url":"https://api.github.com/users/briankung/followers","following_url":"https://api.github.com/users/briankung/following{/other_user}","gists_url":"https://api.github.com/users/briankung/gists{/gist_id}","starred_url":"https://api.github.com/users/briankung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briankung/subscriptions","organizations_url":"https://api.github.com/users/briankung/orgs","repos_url":"https://api.github.com/users/briankung/repos","events_url":"https://api.github.com/users/briankung/events{/privacy}","received_events_url":"https://api.github.com/users/briankung/received_events","type":"User","site_admin":false},"repo":{"id":61582608,"name":"projectcredo","full_name":"briankung/projectcredo","owner":{"login":"briankung","id":2836167,"avatar_url":"https://avatars.githubusercontent.com/u/2836167?v=3","gravatar_id":"","url":"https://api.github.com/users/briankung","html_url":"https://github.com/briankung","followers_url":"https://api.github.com/users/briankung/followers","following_url":"https://api.github.com/users/briankung/following{/other_user}","gists_url":"https://api.github.com/users/briankung/gists{/gist_id}","starred_url":"https://api.github.com/users/briankung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briankung/subscriptions","organizations_url":"https://api.github.com/users/briankung/orgs","repos_url":"https://api.github.com/users/briankung/repos","events_url":"https://api.github.com/users/briankung/events{/privacy}","received_events_url":"https://api.github.com/users/briankung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/briankung/projectcredo","description":"Project Credo v2","fork":false,"url":"https://api.github.com/repos/briankung/projectcredo","forks_url":"https://api.github.com/repos/briankung/projectcredo/forks","keys_url":"https://api.github.com/repos/briankung/projectcredo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/briankung/projectcredo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/briankung/projectcredo/teams","hooks_url":"https://api.github.com/repos/briankung/projectcredo/hooks","issue_events_url":"https://api.github.com/repos/briankung/projectcredo/issues/events{/number}","events_url":"https://api.github.com/repos/briankung/projectcredo/events","assignees_url":"https://api.github.com/repos/briankung/projectcredo/assignees{/user}","branches_url":"https://api.github.com/repos/briankung/projectcredo/branches{/branch}","tags_url":"https://api.github.com/repos/briankung/projectcredo/tags","blobs_url":"https://api.github.com/repos/briankung/projectcredo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/briankung/projectcredo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/briankung/projectcredo/git/refs{/sha}","trees_url":"https://api.github.com/repos/briankung/projectcredo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/briankung/projectcredo/statuses/{sha}","languages_url":"https://api.github.com/repos/briankung/projectcredo/languages","stargazers_url":"https://api.github.com/repos/briankung/projectcredo/stargazers","contributors_url":"https://api.github.com/repos/briankung/projectcredo/contributors","subscribers_url":"https://api.github.com/repos/briankung/projectcredo/subscribers","subscription_url":"https://api.github.com/repos/briankung/projectcredo/subscription","commits_url":"https://api.github.com/repos/briankung/projectcredo/commits{/sha}","git_commits_url":"https://api.github.com/repos/briankung/projectcredo/git/commits{/sha}","comments_url":"https://api.github.com/repos/briankung/projectcredo/comments{/number}","issue_comment_url":"https://api.github.com/repos/briankung/projectcredo/issues/comments{/number}","contents_url":"https://api.github.com/repos/briankung/projectcredo/contents/{+path}","compare_url":"https://api.github.com/repos/briankung/projectcredo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/briankung/projectcredo/merges","archive_url":"https://api.github.com/repos/briankung/projectcredo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/briankung/projectcredo/downloads","issues_url":"https://api.github.com/repos/briankung/projectcredo/issues{/number}","pulls_url":"https://api.github.com/repos/briankung/projectcredo/pulls{/number}","milestones_url":"https://api.github.com/repos/briankung/projectcredo/milestones{/number}","notifications_url":"https://api.github.com/repos/briankung/projectcredo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/briankung/projectcredo/labels{/name}","releases_url":"https://api.github.com/repos/briankung/projectcredo/releases{/id}","deployments_url":"https://api.github.com/repos/briankung/projectcredo/deployments","created_at":"2016-06-20T21:47:57Z","updated_at":"2016-10-13T02:33:57Z","pushed_at":"2016-10-22T16:06:05Z","git_url":"git://github.com/briankung/projectcredo.git","ssh_url":"git@github.com:briankung/projectcredo.git","clone_url":"https://github.com/briankung/projectcredo.git","svn_url":"https://github.com/briankung/projectcredo","homepage":null,"size":457,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":0,"default_branch":"master"}},"base":{"label":"briankung:master","ref":"master","sha":"e185c09c43189d6f149aea8c6f77f6d89de89a5c","user":{"login":"briankung","id":2836167,"avatar_url":"https://avatars.githubusercontent.com/u/2836167?v=3","gravatar_id":"","url":"https://api.github.com/users/briankung","html_url":"https://github.com/briankung","followers_url":"https://api.github.com/users/briankung/followers","following_url":"https://api.github.com/users/briankung/following{/other_user}","gists_url":"https://api.github.com/users/briankung/gists{/gist_id}","starred_url":"https://api.github.com/users/briankung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briankung/subscriptions","organizations_url":"https://api.github.com/users/briankung/orgs","repos_url":"https://api.github.com/users/briankung/repos","events_url":"https://api.github.com/users/briankung/events{/privacy}","received_events_url":"https://api.github.com/users/briankung/received_events","type":"User","site_admin":false},"repo":{"id":61582608,"name":"projectcredo","full_name":"briankung/projectcredo","owner":{"login":"briankung","id":2836167,"avatar_url":"https://avatars.githubusercontent.com/u/2836167?v=3","gravatar_id":"","url":"https://api.github.com/users/briankung","html_url":"https://github.com/briankung","followers_url":"https://api.github.com/users/briankung/followers","following_url":"https://api.github.com/users/briankung/following{/other_user}","gists_url":"https://api.github.com/users/briankung/gists{/gist_id}","starred_url":"https://api.github.com/users/briankung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briankung/subscriptions","organizations_url":"https://api.github.com/users/briankung/orgs","repos_url":"https://api.github.com/users/briankung/repos","events_url":"https://api.github.com/users/briankung/events{/privacy}","received_events_url":"https://api.github.com/users/briankung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/briankung/projectcredo","description":"Project Credo v2","fork":false,"url":"https://api.github.com/repos/briankung/projectcredo","forks_url":"https://api.github.com/repos/briankung/projectcredo/forks","keys_url":"https://api.github.com/repos/briankung/projectcredo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/briankung/projectcredo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/briankung/projectcredo/teams","hooks_url":"https://api.github.com/repos/briankung/projectcredo/hooks","issue_events_url":"https://api.github.com/repos/briankung/projectcredo/issues/events{/number}","events_url":"https://api.github.com/repos/briankung/projectcredo/events","assignees_url":"https://api.github.com/repos/briankung/projectcredo/assignees{/user}","branches_url":"https://api.github.com/repos/briankung/projectcredo/branches{/branch}","tags_url":"https://api.github.com/repos/briankung/projectcredo/tags","blobs_url":"https://api.github.com/repos/briankung/projectcredo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/briankung/projectcredo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/briankung/projectcredo/git/refs{/sha}","trees_url":"https://api.github.com/repos/briankung/projectcredo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/briankung/projectcredo/statuses/{sha}","languages_url":"https://api.github.com/repos/briankung/projectcredo/languages","stargazers_url":"https://api.github.com/repos/briankung/projectcredo/stargazers","contributors_url":"https://api.github.com/repos/briankung/projectcredo/contributors","subscribers_url":"https://api.github.com/repos/briankung/projectcredo/subscribers","subscription_url":"https://api.github.com/repos/briankung/projectcredo/subscription","commits_url":"https://api.github.com/repos/briankung/projectcredo/commits{/sha}","git_commits_url":"https://api.github.com/repos/briankung/projectcredo/git/commits{/sha}","comments_url":"https://api.github.com/repos/briankung/projectcredo/comments{/number}","issue_comment_url":"https://api.github.com/repos/briankung/projectcredo/issues/comments{/number}","contents_url":"https://api.github.com/repos/briankung/projectcredo/contents/{+path}","compare_url":"https://api.github.com/repos/briankung/projectcredo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/briankung/projectcredo/merges","archive_url":"https://api.github.com/repos/briankung/projectcredo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/briankung/projectcredo/downloads","issues_url":"https://api.github.com/repos/briankung/projectcredo/issues{/number}","pulls_url":"https://api.github.com/repos/briankung/projectcredo/pulls{/number}","milestones_url":"https://api.github.com/repos/briankung/projectcredo/milestones{/number}","notifications_url":"https://api.github.com/repos/briankung/projectcredo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/briankung/projectcredo/labels{/name}","releases_url":"https://api.github.com/repos/briankung/projectcredo/releases{/id}","deployments_url":"https://api.github.com/repos/briankung/projectcredo/deployments","created_at":"2016-06-20T21:47:57Z","updated_at":"2016-10-13T02:33:57Z","pushed_at":"2016-10-22T16:06:05Z","git_url":"git://github.com/briankung/projectcredo.git","ssh_url":"git@github.com:briankung/projectcredo.git","clone_url":"https://github.com/briankung/projectcredo.git","svn_url":"https://github.com/briankung/projectcredo","homepage":null,"size":457,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/briankung/projectcredo/pulls/131"},"html":{"href":"https://github.com/briankung/projectcredo/pull/131"},"issue":{"href":"https://api.github.com/repos/briankung/projectcredo/issues/131"},"comments":{"href":"https://api.github.com/repos/briankung/projectcredo/issues/131/comments"},"review_comments":{"href":"https://api.github.com/repos/briankung/projectcredo/pulls/131/comments"},"review_comment":{"href":"https://api.github.com/repos/briankung/projectcredo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/briankung/projectcredo/pulls/131/commits"},"statuses":{"href":"https://api.github.com/repos/briankung/projectcredo/statuses/d4eb4c7c3183b0e57f1e01ea6318ae28cdd820ae"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":13,"deletions":1,"changed_files":3}}
{"actor":{"display_login":"briankung"}}