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
Uninstall arm64 brew
Install Intel brew
Ensure ZSH is the default shell
Setting up VSCode
Installing Oh My ZSH
Installing z for jumping around
Installing ripgrep
Installing Vim
Installing Docker
Installing Node.js
Installing Yarn
2.
Installing Ruby on Rails
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
3.
How you can contribute to the book
Help us to improve the book
4.
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
5.
Rails core principles
DRY
Convention over configuration
6.
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?
7.
Building a new Ruby on Rails application
What are we building?
Live application
Setting up a new Rails application
Removing rack-mini-profiler gem
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
8.
Running server in development environment
Running Rails server
Using Webpack development server
Running the application
9.
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
10.
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
11.
What is CRUD
CRUD in action
REST and CRUD
12.
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
13.
Active Record basics
Object Relational Mapping (ORM)
What is ActiveRecord?
Naming conventions
Overriding table names
Schema conventions
14.
Rails Models
What are models?
Creating Task model
Model and database mapping
Auto generating model definitions
15.
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
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
16.
Adding Tailwind
Learning Tailwind CSS
Installing Tailwind CSS
Tailwind basics
17.
Setting up React environment
React Router
Axios
JS Logger
CSRF token authenticity verification error
Aliases
18.
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
19.
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
20.
Instance variables in Rails controllers
Instance variables in view files
21.
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
22.
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
23.
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
24.
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
25.
Frontend backend separation
Backend as a pure API
Choose design that works best for the team
26.
Moving to an API based architecture
Deleting Rails views
Sending JSON response from the controllers
Configuring React for API based architecture
Updating Rails routes
27.
Building and organizing APIs
How to name routes
Organizing APIs
Building an API
How to effectively use these conventions
28.
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
29.
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
30.
Optimizing slug generation process
Using LIKE operator in SQL for efficient slug generation
Different edge cases while using LIKE query
Handling discussed edge cases
A missed out edge case
Adding REGEX function to SQLite
Updating the set_slug method
Ensuring initializer works in production environment
31.
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
Moving response messages to i18n en.locales
32.
Showing notifications
Features
Technical design
Creating a Toastr component
Storing data in localStorage
Using Axios interceptors
Axios response callbacks
Registering Axios interceptors
33.
Showing a task
Features
Technical design
Implementing show action in TasksController
Building ShowTask Component
Using Rails console to search tasks
34.
Active Record finder methods
find
find_by
where
Don't use dynamic finder methods
finder methods file in Ruby on Rails
35.
Updating task
Features
Technical design
Implementing update task
Moving response messages to i18n en.locales
36.
Deleting task
Features
Technical design
Implementing destroy action in TasksController
Handling task deletion
Deleting a task
37.
Active Record callbacks and object life cycle
List of callbacks
Registering callbacks
Conditionally triggering callbacks
Understanding how the callbacks are triggered
38.
Class methods and scopes
Class methods
Active Record model scopes
Which one to prefer?
39.
User model
Features
Technical design
Creating migration
Adding a User model
Adding users
Connecting User and Task
40.
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
41.
Assigning tasks to user
Features
Technical design
Creating index action for user
Creating users API connector
Updating TaskForm component
Updating CreateTask component
Updating TasksController
Updating EditTask component
Showing user names in ShowTask component
Showing task assignee in Dashboard
Using the as_json method
42.
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 EditTask and ShowTask components
43.
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?
44.
Adding signup feature
Features
Technical design
Adding create action
Moving response messages to i18n en.locales
API connector for authentication
Creating sign up component
45.
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
46.
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
Dealing with stale Active Record cache
47.
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
48.
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
49.
Test coverage
What is test coverage?
Why do we need to have test coverage?
Test coverage using SimpleCov
View the coverage reports
50.
Introducing Factory Bot
Issues with fixtures
What is factory bot?
What is Faker?
Setting up factory bot and Faker
Defining factories
Generating fake data
51.
Authorization
What is authorization?
Features
Technical design
Pundit gem installation
Introducing policies
Adding policy checks in TaskPolicy
Introducing policy scope
52.
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
53.
Avoid premature optimization in API calls
Sending back response data from create or update actions
Avoid the premature optimization mindset
54.
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
55.
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
56.
Starring tasks
Features
Technical design
Storing starred status in DB
Update index action to send starred status
Adding a toggle to star/unstar tasks
57.
Order of items on Active Record models
Items should be presented in an order
58.
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
Testing task deletion and assignment on user deletion
Removing parallelize method from tests
Maintaining test cases execution order
Things to pay attention to
Different styles of writing a test case
Executing a single test case
59.
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
60.
Setting up CircleCI
What is CircleCI?
CircleCI setup
Common CircleCI errors and their solutions
61.
Secure gems with bundle audit
Running audit as part of CI
62.
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
63.
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
64.
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
65.
Keep application controller clean
Using concerns to keep sanity
Moving functionality into a concern
Sanitized version
66.
Using bang method
67.
Deploying the application on Heroku
PostgreSQL database setup
Update Gemfile to use PostgreSQL
Creating a Heroku application
Setting up buildpacks
Setting up Heroku for deployment
Renaming the application
Setting up the Heroku pipeline
68.
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
69.
Exception handling in Ruby
Exceptions in Ruby
Hierarchy of Ruby Exception class
The rescue method catches a class and all its subclasses
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
Do not use exception as control flow
70.
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
71.
Handling cookies
Maintaining state
Cookies
Cookie expiration
Secure parameter
HttpOnly
First party and third party requests and cookies
SameSite
72.
Local storage and Session storage
Local storage
Session storage
73.
XSS attacks
dangerouslySetInnerHTML is dangerous
Compromising third party libraries
74.
CSRF attacks
How the attack works
75.
Mitigating XSS when cookies are used
Do not allow JavaScript to read cookie information
Do not allow hacker to execute JavaScript
76.
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
77.
Cookie vs Auth token
Using cookie to store session data
Using auth token instead of cookie
It is all about tradeoffs
78.
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
79.
Introducing in depth chapters
Congrats on completing the book
About the in depth chapters
80.
PostgreSQL in depth
Using UUID as primary key
Using citext
PostgreSQL database directory
81.
Configuring and connecting to a database
Using only an environment variable
Using database.yml
Config options
Connection preference
82.
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
83.
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
84.
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
85.
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
86.
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
87.
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
88.
Rails generator and bundle commands
What is a bundler?
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
89.
N+1 Queries and memoization
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
joins vs includes
Memoization
90.
Database cleaning and strategies
When to clean the database?
Database cleaning strategies
Database cleaner gem
Cleaning database in production
91.
Rails routing in depth
Namespaces in Rails
Routing with scopes
Scope vs Namespace
92.
Request response cycle in Rails
Domain name server(DNS)
HTTP and HTTPS
Rack interface
Entrypoint of a Rack application
Middleware
Routing
Controllers
References
93.
Debugging test failures
Running an single test
Debugging using puts
Debugging using byebug
94.
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
Miscellaneous errors
95.
More Rails content and goodies
The lib folder and its use cases
Why prefer carriers over view helpers
ActionText
ActionCable