How to setup Rails Guides for offline use

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

Or SSH:
[email protected]:rails/rails.git

Or the Github CLI:
gh repo clone rails/rails

Then cd into the directory and install the gem dependencies:
cd rails-main

bundle install

Then cd into the guides directory:
cd guides

And run:
rake guides:generate

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.




You can also specify the HTML format like this:
rake guides:generate:html

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

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

rails_guides_epub.png 179.96 KB


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

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