Conventions used
There are a number of text conventions used throughout this book.
Code in text
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “All we need to make this code work as we want is to add a couple of has_many
declarations to our models.”
A block of code is set as follows:
class User < ApplicationRecord has_many :posts, -> { order(id: :desc) } end class Post < ApplicationRecord has_many :comments, -> { order(id: :desc) } end
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Rails.application.routes.draw do # The same as: resources :posts, only: %i[index] get "/posts", to: PostsController.action(:index) end
Any command-line input or output is written as follows:
$ git log --format=oneline -- app/models/user.rb | wc -l
Tips or important notes
Appear like this.