How to read local Rails documentation with ri/rdoc tools? - ruby-on-rails

I want to read documentation of gems in terminal. How can I do this with ri tools?
LinuxMint 18.3
Rails 5.1.4

First, make sure you have the Docs on your system. They do not always install with a typical Rails installation.
You can download the doc for a specific gem with
gem rdoc [gem-name] --no-rdoc
The --no-rdoc tells it not to install the HTML version.
If you want the docs for all gems you have installed, you can use
gem rdoc --all --ri --no-rdoc
That may take a few minutes to download.
Once you have the docs downloaded, you can access them with
ri -i
This will give you an interactive prompt where you can search for gems or methods. You can even use tab to autocomplete.

Related

gem install rails -v 4.1.0 stuck with ri-documentation

I've run gem install rails -v 4.1.0 on my server, but somehow it's stuck with
Parsing documentation for rails-4.1.0
Installing ri documentation for rails-4.1.0
Can I abort this? What do I need the ri documentation for? Is it really required?
Though the documentation isn't necessary for rails to run; I have found that it is most likely not stuck.
It took a little over five minutes to complete gem install rails -v 4.1.0 on my quad-core i7, but your experience might be worse if you have a slower computer (it took 15m 47s for just ri and an additional 16m 21s for RDoc on my 4 logical core i5). For those who want to make use of the ri and RDocs you will merely have to wait. For those who have no intent to ever use them you can execute
gem install rails -v 4.1.0 --no-ri --no-rdoc
This took ~30s on my i5 machine.
You can abort it using crtl+c
You can use gem install rails --no-document to install Rails without the documentation
It depends as per your use, but you can get rid of this ri documentations use this command
gem install rails --no-ri --no-rdoc
I had the same issue with Rails 4.2.5. I just used Ctrl+C, and then ran gem install rails again, and it said done.

(MacOSx) Earlier version Rails2.3.8, i installed Rails3.2.0 but i still not able to access new version of Rails. Please help me fix it

Parsing documentation for bundler-1.3.2
Installing ri documentation for bundler-1.3.2
Parsing documentation for rails-3.2.12
Installing ri documentation for rails-3.2.12
Done installing documentation for i18n, multi_json, activesupport, builder, activemodel, rack, rack-cache, rack-test, journey, hike, tilt, sprockets, erubis, actionpack, arel, tzinfo, activerecord, activeresource, mime-types, polyglot, treetop, mail, actionmailer, rack-ssl, thor, rdoc, railties, bundler, rails (58 sec).
29 gems installed
204-252:~ narendra$ rails -v
Rails 2.3.8
204-252:~ narendra$ gem update rails
Updating installed gems**strong text**
Nothing to update
If you're using rbenv you can try running rbenv rehash after updating rails.
If you're in a rails project folder that was built with Rails 2.3.8 then when you run rails -v in that folder it will return that version of rails instead of the latest one. So you could try moving to another folder and see if running rails -v gives you the version you're expecting.
Also, if you installed rails with sudo gem install rails sometimes /usr/bin/rails still points to the old version, so you could update that to point to the new one.
Since rails 3.2.12 is not included in the output of gem list, I suspect you installed the gem with sudo. Installing with sudo and then trying to list the gems without it (or other operations) can give you a different list. Try doing sudo gem list, and if rails 3.2.12 is in there, thats your problem. Try installing it without sudo.

Gem installed rails 2.3.8, but not generate rdoc, how to fix?

I use gem install rails -v=2.3.8 to install rails, and it says rdoc and ri has been generated.
But when I gem server, I can't open the rails doc in browser, it says doc_root/rails-2.3.8/rdoc/index.html not found
I looked into /usr/local/lib/ruby/gems/1.8/doc/rails-2.3.8/rdoc, found it is empty.
How to fix it? How to generate the rdoc by gem?
Maybe re-generating might help: sudo gem rdoc --all
Can you try this DIR "/usr/lib/ruby/gems/1.8/doc/rails-2.3.5/"

Heroku db:push doesnt work. Says it needs taps installed even after taps has been installed

I can't seem to get heroku to db:push, even though I have installed taps. It doesnt seem to believe me. I also checked and found a folder here: /Library/Ruby/Gems/1.8/gems/taps-0.2.23/
UM4345s-MacBook-Pro:photosite $ sudo gem install taps
Password:
Successfully installed rack-1.1.0
Successfully installed sinatra-0.9.2
Successfully installed thor-0.9.9
Successfully installed
rest-client-1.2.0 Successfully
installed sequel-3.0.0 Successfully
installed taps-0.2.23 6 gems installed
Installing ri documentation for
rack-1.1.0... Installing ri
documentation for sinatra-0.9.2...
Installing ri documentation for
thor-0.9.9... Installing ri
documentation for rest-client-1.2.0...
Installing ri documentation for
sequel-3.0.0... Installing ri
documentation for taps-0.2.23...
Installing RDoc documentation for
rack-1.1.0... Installing RDoc
documentation for sinatra-0.9.2...
Installing RDoc documentation for
thor-0.9.9... Installing RDoc
documentation for rest-client-1.2.0...
Installing RDoc documentation for
sequel-3.0.0... Installing RDoc
documentation for taps-0.2.23...
UM4345s-MacBook-Pro:photosite $heroku db:push
Install the Taps gem
to use db commands. On most systems
this will be: sudo gem install taps
UM4345s-MacBook-Pro:photosite $ sudo gem install taps
Password: Successfully installed
taps-0.2.23 1 gem installed Installing
ri documentation for taps-0.2.23...
Installing RDoc documentation for
taps-0.2.23...
UM4345s-MacBook-Pro:photosite$ $heroku db:push
Install the Taps gem
to use db commands. On most systems
this will be: sudo gem install taps
This can be fixed by upgrading your heroku gem with
gem update heroku
You might need a sudo as well depending on your environment.
Is the 'gem' for the current user the same as the run that's run from sudo? I've had a problem with that when using REE or ruby installed from macports. Quick check to compare:
which gem
sudo which gem
gem list | grep tap
sudo gem list | grep tap
It might be worth a try to purge both the taps and heroku gem and reinstall them.
Are you using RVM? If so it's easy to be using the wrong gemset and not know it.

Gem Server and Rails RDoc Not Found

I would like to read Rails documentation locally though gem server.
I go to http://localhost:8808/ and Rails 2.3.3 gem is in the list of the gems installed, but when I click [rdoc] I get:
`/doc_root/rails-2.3.3/rdoc/index.html' not found.
I tried to uninstall and reinstall Rails but I got no effect.
All other gems work properly, why I can't see Rails documentation?
Rails itself has no documentation while you can read rdocs about actionmailer, actionpack, activerecord, activeresource or activesupport.
You can try to explicitly generate ri and rdoc during gem installation. The command is as follows:
$ sudo gem install rails --rdoc --ri
Cheers
http://railsapi.com/
Just download this to your gem docs dir.

Resources