Learn the basics of building a Ruby on Rails application
Enable Rosetta for Terminal on M1 Mac
Install Xcode command line tools
Uninstall arm64 brew
Install Intel brew
Ensure ZSH is the default shell
Enable code command
Enabling auto save feature
Install recommended extensions
Spell checking in VSCode
Installing Prettier plugin
Enable Rosetta in VSCode
Installing Oh My ZSH
Install fonts
Installing z for jumping around
Installing ripgrep
Installing Vim
Installing Docker
Installing Node.js
Installing Yarn
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
Help us to improve the book
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
DRY
Convention over configuration
Navigating through the book
Searching within the book
What is an example?
How to copy and paste code?
When to copy-paste code?
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
Running Rails server
Using Webpack development server
Running the application
What is routing?
How Rails routing works
Dynamic segments in routes
Root URL
More about Rails routing in the official guide
Rails resources
Using only and except to be selective
Difference between singular resource and resources in Rails routes
Adding more RESTful actions
CRUD in action
REST and CRUD
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
Object Relational Mapping (ORM)
What is ActiveRecord?
Naming conventions
Overriding table names
Schema conventions
What are models?
Creating Task model
Model and database mapping
Auto generating model definitions
Task 1
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 as a 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
Learning Tailwind CSS
Installing Tailwind CSS
Tailwind basics
React Router
Axios
JS Logger
CSRF token authenticity verification error
Aliases
BrowserRouter component
Switch component
Route component and associated props
Link Component
Redirect component
Some react-router hooks
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
Why Rails does not have any import statements?
Rails has a strong opinion
Conventions can help reduce complexity
Autoload paths
References
Instance variables in view files
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
Task 2
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
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
Enforcing consistent 2-Space Indentation
Running Git hooks
Git hooks in action
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
Backend as a pure API
Choose design that works best for the team
Deleting Rails views
Sending JSON response from the controllers
Configuring React for API based architecture
Updating Rails routes
How to name routes
Organizing APIs
Building an API
How to effectively use these conventions
Searching with guides
Searching with pry
Searching with Github
Open gem in Github workspace editor
Open gem in VSCode locally
Preparing to display list of tasks
Displaying list of tasks
Importance of a PageLoader in the App Component
Task 3
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
Raw SQL query data migrations
Creating a unique slug upon task creation
Making slug immutable
changed? vs previously_changed?
Moving response messages to i18n en. locales
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
Where can we perform data validations?
General guidelines for the type of validations to be included at various levels
Implementing create action
Value omission in Ruby Hash literals
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
Creating a Toastr component
Storing data in localStorage
Using Axios interceptors
Axios response callbacks
Registering Axios interceptors
Implementing show action in TasksController
Building Show Component
Using Rails console to search tasks
find
find_by
where
Don't use dynamic finder methods
finder methods file in Ruby on Rails
Best practices
Implementing update task
Implementing destroy action in TasksController
Handling task deletion
Destroying all in batches
Deleting a task
List of callbacks
Registering callbacks
Conditionally triggering callbacks
Understanding how the callbacks are triggered
Class methods
Active Record model scopes
Which one to prefer?
Task 4
Creating migration
Adding a User model
Adding users
Connecting User and Task
What is an association in Rails?
Types of associations
Polymorphic associations
Defining associations in User model
Create child record using parent association
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
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
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?
Adding create action
API connector for authentication
Creating sign up component
Creating token for new users
Session controller
Login page
Validating request authenticity in backend
Skipping authentication when not required
Showing logged in user
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?
Frontend changes
Storing information about who created the task
Adding association for task owner
Creating a task using Task owner
Showing task owner
Task 5
Why write tests?
Test setup
Bringing translation helpers into test cases
The setup method
Adding tests for User model
Running tests
Test file naming
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
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
What is authorization?
Pundit gem installation
Introducing policies
Adding policy checks in TaskPolicy
Introducing policy scope
Is the initialize method really necessary?
The super method
Pitfalls of the super method
Conclusion
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
Sending back response data from create or update actions
Avoid the premature optimization mindset
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
Storing progress in DB
Partials in Jbuilder
Fine tuning authorization
Adding toggle for pending/completed tasks
Storing starred status in DB
Update index action to send starred status
Adding a toggle to star/unstar tasks
Task 6
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
Displaying the comment counts
Using counter cache
Resetting the counter cache
Items should be presented in an order
Setting up Task model test
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
Flaky tests
Debugging with minitest-bisect
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
What is CircleCI?
CircleCI setup
Common CircleCI errors and their solutions
Running audit as part of CI
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
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
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
Using concerns to keep sanity
Moving functionality into a concern
Sanitized version
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
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
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
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
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
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
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
WebSockets vs Polling
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
Maintaining state
Cookies
Cookie expiration
Secure parameter
HttpOnly
First party and third party requests and cookies
SameSite
Local storage
Session storage
SQL injection
Use \A & \z as anchors in regex validations
Mass assignment
Avoiding unsafe reflection
Dangerous send
File access vulnerabilities
Redirection
dangerouslySetInnerHTML is dangerous
Compromising third party libraries
How the attack works
Do not allow JavaScript to read cookie information
Do not allow hacker to execute JavaScript
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
Using cookie to store session data
Using auth token instead of cookie
It is all about tradeoffs
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
Congrats on completing the book
About the in depth chapters
Using UUID as primary key
Using citext
PostgreSQL database directory
Using only an environment variable
Using database.yml
Config options
Connection preference
Inspecting keys
Inspecting memory usage
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 save and destroy methods
Exception handling and rolling back
Nested Transactions
Transaction Callbacks
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
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
Consequences of Dangerous migrations
Downtime
Detecting unsafe migrations
Dangerous migrations and their corresponding checks
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
What is Metaprogramming?
Metaclasses
Usage of send in Ruby
Defining methods dynamically
Defining missing methods on the fly
Macros in Rails
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
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
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
Rails Engines
When should you use a Rails Engine?
Creating a Rails Engine
Using Engines within host applications
Overriding Engine classes
What is Rails Caching?
How to use Low-level caching?
Cache keys in detail
When to Use Low-level Caching?
When not to use Low-level caching?
Using Redis for Efficient Caching
Memoization
Counter culture as an alternative to counter cache
What are carriers?
When and how are carriers used?
Why not helpers or services?
When to clean the database?
Database cleaning strategies
Database cleaner gem
Cleaning database in production
Namespaces in Rails
Routing with scopes
Scope vs Namespace
What are Parameters?
Require and Permit
Domain name server(DNS)
HTTP and HTTPS
Rack interface
Entrypoint of a Rack application
Middleware
Routing
Controllers
Running an single test
Debugging using puts
Debugging using byebug
rbenv path not added
Ruby installation missing psych error
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
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
Performance optimization
Debouncing
Throttling
Types of Schema Dumps
Benefits of Using SQL Schema Dumps
Impact on Development
Switching to SQL Schema Dumps
Handling Git Conflicts When Switching to :sql Format
Handling Custom SQL Statements in Migrations
Adoption of Advanced Constraints in Rails
What is a PostgreSQL JSONB column?
Use cases of storing JSON data in relational database columns
Using JSON columns in Rails
store and store_accessor
Considerations for storing JSON data in PostgreSQL database columns
The lib folder and its use cases
ActionModel::Dirty
ActionText
ActionCable
Must Read Articles
Debugging Videos