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!
Copyright © 2021 Jogjafile Inc.
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-docif you runri ActiveRecord::Baseyou should see:(I believe
show-docdoes not work forActiveRecord::Basebecause 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 samericommand 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.