Clients
Services
Blog
Contact
Learn Ruby on Rails Book
Learn the basics of building a Ruby on Rails application
Search Book
⌘K
to navigate
Enter
to select
Esc
to close
1.
Setting up macOS
Enable Rosetta for Terminal on M1 Mac
Install Xcode command line tools
Uninstall arm64 brew
Install Intel brew
Ensure ZSH is the default shell
2.
Setting up VSCode
Enable code command
Enabling auto save feature
Install recommended extensions
Spell checking in VSCode
Installing Prettier plugin
Enable Rosetta in VSCode
3.
Setting up workspace
Installing Oh My ZSH
Install fonts
Installing z for jumping around
Installing ripgrep
Installing Vim
Installing Docker
Installing Node.js
Installing Yarn
4.
Installing Ruby on Rails
Install system packages
Install rbenv
Installing Ruby on Rails on macOS
Installing Ruby on Rails in other operating systems
TypeError for Rails project in M1 Mac
Rbenv Ruby build definitions not found error
5.
How you can contribute to the book
Help us to improve the book
6.
React.js over Rails view
Free materials to learn JavaScript
Free materials to learn React.js
Free Materials to learn React hooks
Free materials to learn Formik
Free material to learn how to use Chrome dev tools
7.
Rails core principles
DRY
Convention over configuration
8.
Keywords and familiarizing with UI
Navigating through the book
Searching within the book
What is an example?
How to copy and paste code?
When to copy-paste code?
9.
Building a new Ruby on Rails application
What are we building?
Live application
Setting up a new Rails application
Setting a specific Webpacker version
Update to stylesheet pack tag
Configuring default Ruby and Node.js versions
Removing fixtures
Creating database
Starting the server
Verify Ruby and NodeJS versions
10.
Running server in development environment
Running Rails server
Using Webpack development server
Running the application
11.
Basics of Ruby on Rails routing
What is routing?
How Rails routing works
Dynamic segments in routes
Root URL
More about Rails routing in the official guide
12.
RESTful routes in Ruby on Rails
Rails resources
Using only and except to be selective
Difference between singular resource and resources in Rails routes
Adding more RESTful actions
13.
What is CRUD
CRUD in action
REST and CRUD
14.
Rails migration
What is a Rails migration?
Creating tasks table
schema.rb file is the final source of truth
Rails version in the migration file
Don't edit existing migrations
Upcoming content about migration
15.
Active Record basics
Object Relational Mapping (ORM)
What is ActiveRecord?
Naming conventions
Overriding table names
Schema conventions
16.
Rails Models
What are models?
Creating Task model
Model and database mapping
Auto generating model definitions
17.
Rails console
Introducing Rails console
Finding column names of the table
Finding number of records in the table
Creating a new task using Task.create
Clearing the console
Reloading the console or an object
Getting value of the last expression
Use c for shortcut
Switching the environment
Command history
Use source location to know the location of the code
User helper
Working in a sandbox
Use exit to quit console
Simple prompt
18.
Adding Tailwind
Learning Tailwind CSS
Installing Tailwind CSS
Tailwind basics
19.
Setting up React environment
React Router
Axios
JS Logger
CSRF token authenticity verification error
Aliases
20.
Basics of React Router Dom
BrowserRouter component
Switch component
Route component and associated props
Link Component
Redirect component
Some react-router hooks
21.
Adding Tasks controller
Controller and actions
Defining routes to map requests to controller actions
Adding view file
A gentle introduction to Application controller
Using Rails console to add tasks
Displaying a list of tasks
Rails MimeResponds
22.
Loading behavior of Ruby on Rails
Why Rails does not have any import statements?
Rails has a strong opinion
Conventions can help reduce complexity
Autoload paths
References
23.
Instance variables in Rails controllers
Instance variables in view files
24.
Model validations
Making title field a required field
Verifying validation
Caveats with validations at the Rails level
Adding migration to make title field NOT NULL
Verifying validation using console
Adding length validation to title field
25.
Bring React.js to Rails
Adding React.js to Rails
Webpacker and webpack-dev-server compatibility issues
Setup React Webpacker pipeline
Update the babel config
Remove unnecessary pack files
Keeping src folder as the entry point
Directory structure
26.
Linting and Formatting Code
Wheel from BigBinary
Rubocop
Running Rubocop on all Ruby files
Setup pre-commit Git hook
ESLint
Prettier
Formatting all JavaScript files
Configuring VSCode settings
Adding .editorconfig
Running Git hooks
Git hooks in action
27.
Reusable components
Features
Technical design
Custom Tailwind colors
Install Ramda
Install classnames
Button component
Navbar component
Add remixicon to dependencies
Container component
Input component
Table component
PageLoader component
Tooltip Component
7-in-1 Sass Pattern
Styling Tooltip Component
The Ampersand Operator in Sass
The BEM Model
References
28.
Frontend backend separation
Backend as a pure API
Choose design that works best for the team
29.
Moving to an API based architecture
Deleting Rails views
Sending JSON response from the controllers
Configuring React for API based architecture
Updating Rails routes
30.
Building and organizing APIs
How to name routes
Organizing APIs
Building an API
How to effectively use these conventions
31.
Searching the Rails docs
Searching with guides
Searching with pry
Searching with Github
Open gem in Github workspace editor
Open gem in VSCode locally
32.
Displaying list of tasks
Features
Technical design
Preparing to display list of tasks
Displaying list of tasks
Importance of a PageLoader in the App Component
33.
Adding slug to task
What is a slug?
Generating a slug to use in the URL
Unique indexes and why we use them
Race conditions
Handling race conditions
Adding a unique constraint in database
Adding a null constraint for slug
Creating a unique slug upon task creation
Making slug immutable
Moving response messages to i18n en.locales
34.
Optimizing slug generation process
Using LIKE operator in SQL for efficient slug generation
Different edge cases while using LIKE query
Handling discussed edge cases
Some missed out edge cases
Adding REGEX function to SQLite
Updating the set_slug method
Ensuring initializer works in production environment
count vs length vs size
35.
Adding a new task using create action
Features
Technical design
Implementing create action
Singular vs plural naming conventions
Adding a route for creating a new task
Handle parent key in API connector functions
Moving response messages to i18n en.locales
36.
Data validations
Where can we perform data validations?
General guidelines for the type of validations to be included at various levels
37.
Showing notifications
Features
Technical design
Creating a Toastr component
Storing data in localStorage
Using Axios interceptors
Axios response callbacks
Registering Axios interceptors
38.
Showing a task
Features
Technical design
Implementing show action in TasksController
Building Show Component
Using Rails console to search tasks
39.
Active Record finder methods
find
find_by
where
Don't use dynamic finder methods
finder methods file in Ruby on Rails
Best practices
40.
Updating task
Features
Technical design
Implementing update task
Moving response messages to i18n en.locales
41.
Deleting task
Features
Technical design
Implementing destroy action in TasksController
Handling task deletion
Destroying all in batches
Deleting a task
42.
Active Record callbacks and object life cycle
List of callbacks
Registering callbacks
Conditionally triggering callbacks
Understanding how the callbacks are triggered
43.
Class methods and scopes
Class methods
Active Record model scopes
Which one to prefer?
44.
User model
Features
Technical design
Creating migration
Adding a User model
Adding users
Connecting User and Task
45.
Defining associations and best practices
What is an association in Rails?
Types of associations
Polymorphic associations
Defining associations in User model
Create child record using parent association
46.
Assigning tasks to user
Features
Technical design
Creating index action for user
Creating users API connector
Updating Form component
Updating Create component
Updating TasksController
Updating Edit component
Showing user names in Show component
Showing task assignee in Dashboard
Using the as_json method
47.
Use Jbuilder to render JSON
Features
Technical design
Updating TasksController to render Jbuilder template
Adding Jbuilder template for show action of TasksController
Using extract! method
Updating default response format
Adding lambda route constraints
Updating Edit and Show components
48.
Authentication
Bcrypt gem
Adding credentials fields to User model
Securing password
Adding credential validations
The freeze method in Ruby
What is the frozen_string_literal comment?
49.
Adding signup feature
Features
Technical design
Adding create action
Moving response messages to i18n en.locales
API connector for authentication
Creating sign up component
50.
Adding login feature
Features
Technical design
Creating token for new users
Session controller
Login page
Validating request authenticity in backend
Skipping authentication when not required
Moving response messages to i18n en.locales
Showing logged in user
51.
Setting up Rake tasks
What is Rake and why do we need it?
Setting up Rake tasks
Executing the Rake task
Finalizing the Rake setup
Importance of ./bin/setup file
Dealing with stale Active Record cache
How to add TODO comments?
52.
Adding logout feature
Features
Technical design
Frontend changes
Storing information about who created the task
Adding association for task owner
Creating a task using Task owner
Showing task owner
53.
Testing User model
Why write tests?
Test setup
Bringing translation helpers into test cases
The setup method
Adding tests for User model
Running tests
Test file naming
54.
Test coverage
What is test coverage?
Why do we need to have test coverage?
Test coverage using SimpleCov
View the coverage reports
Do not write tests to satisfy test coverage alone
55.
Introducing Factory Bot
Issues with fixtures
What is factory bot?
What is Faker?
Setting up factory bot and Faker
Defining factories
Generating fake data
Rails console in test env
56.
Authorization
What is authorization?
Features
Technical design
Pundit gem installation
Introducing policies
Adding policy checks in TaskPolicy
Introducing policy scope
57.
Adding comments to tasks
Features
Technical design
Creating Comment model
Adding tests for the Comment model
Adding route for Comments
Adding Comments controller
Adding Comments to the task show page
delete vs destroy methods
58.
Avoid premature optimization in API calls
Sending back response data from create or update actions
Avoid the premature optimization mindset
59.
Using Enums in Rails
What is an Enum?
Why should we use Enums?
Migration for Enum type
How Enums are stored in database?
How to use Enums?
Querying using Enum types
Using a string column for Enums in database
Using suffixes and prefixes with Enum
60.
Marking a task as complete
Features
Technical design
Storing progress in DB
Partials in Jbuilder
Fine tuning authorization
Adding toggle for pending/completed tasks
Moving response messages to i18n en.locales
61.
Starring tasks
Features
Technical design
Storing starred status in DB
Update index action to send starred status
Adding a toggle to star/unstar tasks
62.
N+1 Queries
What is an N+1 query?
Query with includes method
Preload
Eager load
Specifying multiple associations in includes method
Loading nested associations with includes
Query with joins method
Query with nested joins
joins vs includes
63.
Using counter cache to display comment counts
Displaying the comment counts
Using counter cache
Resetting the counter cache
64.
Order of items on Active Record models
Items should be presented in an order
65.
Deep diving into unit testing
Setting up Task model test
The setup method
Testing timestamps columns
Testing association and length
Setup method and mutation
Testing exceptions
Testing expressions
Testing presence of an attribute
Testing for the uniqueness of slugs
Active Record reload method and its usage
Handling edge cases part of slug generation
Creating multiple records
Testing task deletion and assignment on user deletion
Maintaining test cases execution order
Things to pay attention to
Different styles of writing a test case
Executing a single test case
Env variables and flaky tests
Debugging with minitest-bisect
66.
Controller tests
Writing functional controller tests
HTTP helper methods
Named route helpers
Testing Home Controller
Testing Tasks controller
Testing Comments controller
Testing Users controller
Testing Sessions controller
Testing updates to Bcrypt password
67.
Setting up CircleCI
What is CircleCI?
CircleCI setup
Common CircleCI errors and their solutions
68.
Secure gems with bundle audit
Running audit as part of CI
69.
Background job processing using Sidekiq
Choosing a backend adapter
Configuring Sidekiq
Creating a job
Executing the job
Active Job callbacks
Enqueuing jobs to Sidekiq
Testing Sidekiq jobs
Clearing Sidekiq queues
70.
Handling idempotency when sending emails using Sidekiq
Features
Technical design
Sidekiq worker
What is idempotency?
Action Mailer
Setting up base
Creating models
Adding validations
Adding preferences for existing users
Creating the controller
Why we do not need a preference policy?
Building the UI for user preference
Implementing task mailer
Use case of secrets.yml file
Creating schedule.yml
Adding logic to schedule cron jobs
Adding TodoNotifications functionality
Moving messages to i18n en.locales
Testing PreferencesController
71.
Testing Sidekiq based email delivery feature
Adding tests for the User model
Adding tests for the Preference model
Adding tests for the UserNotification model
Adding tests for the TodoNotificationsWorker
Adding tests for the UserNotificationsWorker
Creating support or helper files for tests
Adding tests for the TodoNotificationService
Adding tests for the TaskMailer
72.
Keep application controller clean
Using concerns to keep sanity
Moving functionality into a concern
Sanitized version
73.
Using bang method
74.
Deploying the application on Heroku
PostgreSQL database setup
Update Gemfile to use PostgreSQL
Add Uglifier
Update the manifest file
Update engines in package.json
Creating a Heroku application
Setting up buildpacks
Setting up Heroku for deployment
Renaming the application
Setting up the Heroku pipeline
app.json file
75.
Configure Sidekiq in Heroku
Credit card details
Verifying account
Adding the heroku-redis add on
A brief introduction to Procfile and Heroku dynos
Activating Heroku dynos
Gotchas with Sidekiq in Heroku
Viewing the Sidekiq Web UI
76.
Exception handling in Ruby
Exceptions in Ruby
Hierarchy of Ruby Exception class
The rescue method catches a class and all its subclasses
Certain exceptions and when they are raised
Raising error using class
Default rescue is StandardError
Catching multiple types of exceptions in one shot
Catching exception in a variable
Custom exceptions
rescue nil
Exception handling in Ruby on Rails using rescue_from
Rescuing from specific exception
Do not use exception as control flow
Using bang methods in controller actions
77.
How to interpret a stacktrace
What is a stack trace?
How to log stack trace of an exception
Interpreting Rails stack trace
Video on how to interpret a stack trace
78.
Generating a PDF report
Features
Technical design
Add the wicked_pdf gem
Add the PDF layout
Add the report routes
Viewing Rails routes
Nested routes with namespacing
Generating nested controller
PDF generation worker
Value omission in Ruby Hash literals
Create a task model scope
Create PDF content view
Rendering views outside controller
Report controller
Frontend logic for downloading a file
The Content-Disposition header
What are Blobs?
Object URLs
Creating and releasing object URLs
The saveAs method
Limitations of this logic
Better way to handles files
Things you can try out on your own
79.
Optimizing PDF report feature
Features
Technical design
What is Active Storage?
Initialize Google Cloud bucket
Handle env variables
The String dump method
Always add env variables to secrets.yml
Add Active Storage
Updating environments to use 3rd party provider
What is Action Cable?
Setup Action Cable to send live notifications
Move hardcoded messages to translations file
Setting up Action Cable in the frontend side
Add alias for channels folder
Create progress animation using framer-motion library
Testing Action Cable
References
80.
Handling cookies
Maintaining state
Cookies
Cookie expiration
Secure parameter
HttpOnly
First party and third party requests and cookies
SameSite
81.
Local storage and Session storage
Local storage
Session storage
82.
XSS attacks
dangerouslySetInnerHTML is dangerous
Compromising third party libraries
83.
CSRF attacks
How the attack works
84.
Mitigating XSS when cookies are used
Do not allow JavaScript to read cookie information
Do not allow hacker to execute JavaScript
85.
Preventing CSRF attacks
CSRF token authenticity
How Rails implements forgery protection
CSRF protection when plain vanilla Rails form is used
How CSRF token works when we are using React.js
My application does not use Rails layout
Skipping CSRF protection
Handling unverified requests
86.
Cookie vs Auth token
Using cookie to store session data
Using auth token instead of cookie
It is all about tradeoffs
87.
HSTS and Rails
HSTS
Connections start with http
HSTS ensures HTTPS at the browser level
What are SSL strip attacks and how does it work?
HSTS Preloading using hstspreload.org
Avoid hotspots at public wifi
88.
Introducing in depth chapters
Congrats on completing the book
About the in depth chapters
89.
PostgreSQL in depth
Using UUID as primary key
Using citext
PostgreSQL database directory
90.
Configuring and connecting to a database
Using only an environment variable
Using database.yml
Config options
Connection preference
91.
ActiveRecord Transactions in depth
What are Transactions?
Transactions in Active Record
Transactions in action
Different Active Record classes in a single transaction
Calling transactions on ActiveRecord::Base vs Model Class vs Model Instance
Transactional nature of
Exception handling and rolling back
Nested Transactions
Transaction Callbacks
92.
Webpacker in Depth
What is Webpacker?
Webpacker related files
JavaScript codebase in Rails
The packs directory
Difference between Webpacker and Sprockets
Using CSS with Webpacker
Significance of stylesheet pack tag
Handling Webpacker config for each environment
Webpacker during deployment
Webpacker module and version issues
Downside of not running Webpack development server during development
Advantages of running Webpack development server during development
93.
Rails migrations in depth
Raw SQL migrations and their complications
Reversible and non reversible migrations
Possible operations in Rails migrations
Seeding initial data
Internals of migrations and schema loads
Bulk mode migrations
94.
Strong migrations
Consequences of Dangerous migrations
Downtime
Detecting unsafe migrations
Dangerous migrations and their corresponding checks
References
95.
Loading behavior of Ruby on Rails in depth
Including files outside of the app directory
What is autoloading?
Concept of reloading
Eager loading
Viewing the autoloaded modules
Inbuilt Ruby autoload mechanism
Rails in depth
96.
Rails Macros and Metaprogramming
What is Metaprogramming?
Metaclasses
Usage of send in Ruby
Defining methods dynamically
Defining missing methods on the fly
Macros in Rails
97.
Summarizing Rails naming conventions
General naming conventions in Ruby
Naming conventions in Active Record model
Naming model associations
Naming conventions for databases
Naming conventions for Controllers
Naming conventions for routes
Naming conventions for Views
Naming conventions in services, workers and carriers
Naming conventions and folder structure for tests
98.
Generic naming patterns
Choose names that are descriptive and meaningful
Do not unnecessarily elaborate variable names
Do not abbreviate variable names
Using verbs while naming functions
Use appropriate prefixes and suffixes
99.
Rails generator and bundle commands
What is a bundler?
Don't use sudo bundle install
Gemfile and Gemfile.lock
bundle exec command
Updating gems manually
Rails generators
Rails generate command
Working with migration generators
Generating scaffold
Rails destroy command
Rails command line executable
Creating a Rails app from a specific Rails commit
100.
Rails Engines
Rails Engines
When should you use a Rails Engine?
Creating a Rails Engine
Using Engines within host applications
Overriding Engine classes
101.
Memoization
Memoization
102.
Counter culture
Counter culture as an alternative to counter cache
103.
Database cleaning and strategies
When to clean the database?
Database cleaning strategies
Database cleaner gem
Cleaning database in production
104.
Rails routing in depth
Namespaces in Rails
Routing with scopes
Scope vs Namespace
105.
Overview of Rails Parameters
What are Parameters?
Require and Permit
106.
Request response cycle in Rails
Domain name server(DNS)
HTTP and HTTPS
Rack interface
Entrypoint of a Rack application
Middleware
Routing
Controllers
References
107.
Debugging test failures
Running an single test
Debugging using puts
Debugging using byebug
108.
Dealing with errors
rbenv path not added
Webpacker compatibility issue
rails command does not exist
Ruby and Apple Silicon
Fixing failing ruby-build
No response from PostgreSQL service
Sass syntax error in production
PostgreSQL disallowing indexing on large fields
Miscellaneous errors
109.
Mocking API calls
What is a stub?
What is mock?
Difference between stub and mock
Why mocking API calls are required?
Webmock
Mock API in a DRY fashion
110.
Debouncing and Throttling
Performance optimization
Debouncing
Throttling
References
111.
More Rails content and goodies
The lib folder and its use cases
Why prefer carriers over view helpers
ActionModel::Dirty
ActionText
ActionCable
112.
Other reference materials to go through
Must Read Articles
Debugging Videos