How to setup Rails Guides for offline use

This lesson is from Full Stack Rails Mastery.

The official Ruby on Rails Guides are an essential part of a working Rails developer’s reference library. While it’s easy enough to look them up online, it’s also a great idea to keep a copy on your computer for easy offline access.

It comes in handy if you find yourself somewhere with weak or no internet connectivity and need to look something up quickly.

The guides are inside the Rails repository – https://github.com/rails/rails/tree/main/guides.

Start by downloading the repo to your machine. You can download the zipped file or run one of the following commands on your terminal.

Using the HTTPS url:

git clone https://github.com/rails/rails.git
Enter fullscreen mode Exit fullscreen mode

Or SSH:

[email protected]:rails/rails.git
Enter fullscreen mode Exit fullscreen mode

Or the Github CLI:

gh repo clone rails/rails
Enter fullscreen mode Exit fullscreen mode

Then cd into the directory and install the gem dependencies:

cd rails-main
bundle install
Enter fullscreen mode Exit fullscreen mode

Then cd into the guides directory:

cd guides
Enter fullscreen mode Exit fullscreen mode

And run:

rake guides:generate
Enter fullscreen mode Exit fullscreen mode

That will generate the HTML version of the guides and put them in a new output directory inside the guides directory. You can open output/index.html to see the guides homepage, which links to all the guides.

Rails Guides Index

You can also specify the HTML format like this:

rake guides:generate:html
Enter fullscreen mode Exit fullscreen mode

Note that this is the Edge version of the guides, since we are generating them from the main branch.

If you want to generate the guides for a specific Rails version, you can pass RAILS_VERSION as an argument:

rake guides:generate:epub RAILS_VERSION=7.1.0
Enter fullscreen mode Exit fullscreen mode

If you prefer an ebook format to use on your Kindle, Apple Books or other ereader device, you can generate the guides in epub by running:

rake guides:generate:epub
Enter fullscreen mode Exit fullscreen mode

Rails Guides EPUB

Note that the old kindle option for generating .mobi files has been deprecated.

Some other arguments you can pass are ONLY (if you only want specify specific guides):

rake guides:generate ONLY=assoc,migrations
Enter fullscreen mode

What’s cool is that since you have the code for generating the guides, you can customise them any way you like!


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top