Is it possible to view/browse Rails documentation with pry? How?
(pry-rails appears to be for project source, and pry-doc covers Core Ruby.)
Is ri the preferred local doc browsing tool for Rails?
Thanks!
Is it possible to view/browse Rails documentation with pry? How?
(pry-rails appears to be for project source, and pry-doc covers Core Ruby.)
Is ri the preferred local doc browsing tool for Rails?
Thanks!
Pry will only show you documentation for dependencies that you have explicitly loaded. The easiest way to get all the Rails dependencies is to run pry in a Rails project's directory like so:
Now you're ready to see Rails' internal documentation through pry. However, as you noted Rails' documentation is written with ri in mind. So instead of using
show-doc
if you runri ActiveRecord::Base
you should see:(I believe
show-doc
does not work forActiveRecord::Base
because there's a#:nodoc:
directive in that file's source code. Perhaps someone can chime in in the comments or add an edit.)Alternatively, you can load each dependency you want manually. If you opened up a normal pry session and run
require 'active_record'
the sameri
command will work.This should work with the rails console as well if you use the pry-rails gem or a custom initializer to set pry as the default REPL.