{"issue":{"state":"open","pull_request":{"diff_url":"https://github.com/rails/rails/pull/3509.diff","html_url":"https://github.com/rails/rails/pull/3509","patch_url":"https://github.com/rails/rails/pull/3509.patch"},"user":{"avatar_url":"https://secure.gravatar.com/avatar/76a777ff80f30bd3b390e275cce625bc?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"76a777ff80f30bd3b390e275cce625bc","url":"https://api.github.com/users/amatsuda","login":"amatsuda","id":11493},"milestone":null,"updated_at":"2011-11-05T18:02:12Z","labels":[],"assignee":null,"comments":3,"closed_at":null,"url":"https://api.github.com/repos/rails/rails/issues/3509","body":"Currently, methods available in Rails console (such as `app`, `helper`, `reload`, etc.) are defined on Ruby's top level.\r\nThat means, these methods are injected into all Objects. In fact, we can do something funny like this on our Rails console.\r\n\r\n```\r\n> puts 'foobar'.send(:app)\r\n#<ActionDispatch::Integration::Session:0x007ff67c0f8f28>\r\n```\r\n\r\n```\r\n> puts nil.send(:controller)\r\n#<ApplicationController:0x007ff681bdf5e0>\r\n```\r\n\r\nReading IRB code, I found the IRB way is, to define this sort of methods in a module named IRB::ExtendCommandBundle, then IRB automatically includes (extends) these methods in IRB console's context.\r\nFor example, you see, you can call `irb_jobs` method in your IRB but the following code raises `NoMethodError: undefined method `irb_jobs'`, because this method is mixed into IRB's \"main\" context via IRB::ExtendCommandBundle.\r\n\r\n```\r\nObject.new.send(:irb_jobs)\r\n```\r\n\r\nAttached a patch and tests for Rails console to follow this IRB way. I confirmed it runs on MRI 1.8, 1.9, JRuby and Rubinius.","html_url":"https://github.com/rails/rails/issues/3509","number":3509,"title":"move Rails console top level methods to IRB context","id":2141143,"created_at":"2011-11-04T06:33:30Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/1250da547f7579de129ecb737ec3d080?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"1250da547f7579de129ecb737ec3d080","url":"https://api.github.com/users/dvyjones","login":"dvyjones","id":24421},"updated_at":"2011-11-05T18:02:12Z","url":"https://api.github.com/repos/rails/rails/issues/comments/2641583","body":"[This](https://gist.github.com/1341827) is how I use pry for the rails console. I'll test if this works on pry as soon as I'm done running the rails tests.","id":2641583,"created_at":"2011-11-05T18:02:12Z"}}