The Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA. See credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified
Book created for educational purposes and is not affiliated with group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners
https://goalkicker.com/
Content
1-1
Content list
1-2
About
1-3
Chapter 1: Getting started with Ruby on Rails
1-4
Section 1.1: Creating a Ruby on Rails Application
1-5
Section 1.2: Create a new Rails app with your choice of database and including the RSpec Testing Tool
1-6
Section 1.3: Generating A Controller
1-7
Section 1.4: Installing Rails
1-8
Section 1.5: Create a new Rails app with a non-standard database adapter
1-9
Section 1.6: Creating Rails APIs in JSON
1-10
Section 1.7: Generate a Resource with Scaolds
1-11
Chapter 2: Routing
1-12
Section 2.1: Resource Routing (Basic)
1-13
Section 2.2: Constraints
1-14
Section 2.3: Scoping routes
1-15
Section 2.4: Concerns
1-16
Section 2.5: Root route
1-17
Section 2.6: Split routes into multiple files
1-18
Section 2.7: Additional RESTful actions
1-19
Section 2.8: Member and Collection Routes
1-20
Section 2.9: Mount another application
1-21
Section 2.10: Nested Routes
1-22
Section 2.11: Redirection
1-23
Section 2.12: Redirects and Wildcard Routes
1-24
Section 2.13: Scope available locales
1-25
Section 2.14: URL params with a period
1-26
Chapter 3: ActiveRecord
1-27
Section 3.1: Creating a Model via generator
1-28
Section 3.2: Introduction to Callbacks
1-29
Section 3.3: Creating a Model manually
1-30
Section 3.4: Manually Testing Your Models
1-31
Section 3.5: Creating A Migration
1-32
Section 3.6: Create a Join Table using Migrations
1-33
Section 3.7: Using a model instance to update a row
1-34
Chapter 4: Views
1-35
Section 4.1: Structure
1-36
Section 4.2: Partials
1-37
Section 4.3: AssetTagHelper
1-38
Section 4.4: Replace HTML code in Views
1-39
Section 4.5: HAML - an alternative way to use in your views
1-40
Chapter 5: ActiveRecord Migrations
1-41
Section 5.1: Adding multiple columns to a table
1-42
Section 5.2: Add a reference column to a table
1-43
Section 5.3: Rollback migrations
1-44
Section 5.4: Add a new column with an index
1-45
Section 5.5: Run specific migration
1-46
Section 5.6: Redo migrations
1-47
Section 5.7: Add a new column to a table
1-48
Section 5.8: Remove an existing column from a table
1-49
Section 5.9: Add column with default value
1-50
Section 5.10: Running migrations in dierent environments
1-51
Section 5.11: Create a new table
1-52
Section 5.12: Running migrations
1-53
Section 5.13: Change an existing column’s type
1-54
Section 5.14: Create a hstore column
1-55
Section 5.15: Create a join table
1-56
Section 5.16: Add a self reference
1-57
Section 5.17: Create an array column
1-58
Section 5.18: Add an unique column to a table
1-59
Section 5.19: Checking migration status
1-60
Section 5.20: Changing Tables
1-61
Section 5.21: Adding a NOT NULL constraint to existing data
1-62
Section 5.22: Forbid null values
1-63
Chapter 6: Rails Best Practices
1-64
Section 6.1: Fat Model, Skinny Controller
1-65
Section 6.2: Domain Objects (No More Fat Models)
1-66
Section 6.3: Beware of default_scope
1-67
Section 6.4: Convention Over Configuration
1-68
Section 6.5: Don't Repeat Yourself (DRY)
1-69
Section 6.6: You Ain’t Gonna Need it (YAGNI)
1-70
Chapter 7: Naming Conventions
1-71
Section 7.1: Controllers
1-72
Section 7.2: Models
1-73
Section 7.3: Filenames and autoloading
1-74
Section 7.4: Views and Layouts
1-75
Section 7.5: Models class from Controller name
1-76
Chapter 8: ActionCable
1-77
Section 8.1: User Authentication
1-78
Section 8.2: [Basic] Server Side
1-79
Section 8.3: [Basic] Client Side (Coeescript)
1-80
Chapter 9: ActiveModel
1-81
Section 9.1: Using ActiveModel::Validations
1-82
Chapter 10: User Authentication in Rails
1-83
Section 10.1: Authentication using Devise
1-84
Section 10.2: Devise Controller Filters & Helpers
1-85
Section 10.3: Omniauth
1-86
Section 10.4: has_secure_password
1-87
Section 10.5: has_secure_token
1-88
Chapter 11: ActiveRecord Associations
1-89
Section 11.1: Polymorphic association
1-90
Section 11.2: Self-Referential Association
1-91
Section 11.3: belongs_to
1-92
Section 11.4: has_one
1-93
Section 11.5: has_many
1-94
Section 11.6: The has_many :through association
1-95
Section 11.7: The has_one :through association
1-96
Section 11.8: The has_and_belongs_to_many association
1-97
Chapter 12: ActiveRecord Validations
1-98
Section 12.1: Validating length of an attribute
1-99
Section 12.2: Validates format of an attribute
1-100
Section 12.3: Validating presence of an attribute
1-101
Section 12.4: Custom validations
1-102
Section 12.5: Validates inclusion of an attribute
1-103
Section 12.6: Grouping validation
1-104
Section 12.7: Validating numericality of an attribute
1-105
Section 12.8: Validate uniqueness of an attribute
1-106
Section 12.9: Skipping Validations
1-107
Section 12.10: Confirmation of attribute
1-108
Section 12.11: Using :on option
1-109
Section 12.12: Conditional validation
1-110
Chapter 13: ActiveRecord Query Interface
1-111
Section 13.1: .where
1-112
Section 13.2: .where with an array
1-113
Section 13.3: Scopes
1-114
Section 13.4: Get first and last record
1-115
Section 13.5: Ordering
1-116
Section 13.6: where.not
1-117
Section 13.7: Includes
1-118
Section 13.8: Joins
1-119
Section 13.9: Limit and Oset
1-120
Section 13.10: .find_by
1-121
Section 13.11: .delete_all
1-122
Section 13.12: ActiveRecord case insensitive search
1-123
Section 13.13: .group and .count
1-124
Section 13.14: .distinct (or .uniq)
1-125
Chapter 14: ActionMailer
1-126
Section 14.1: Basic Mailer
1-127
Section 14.2: Generating a new mailer
1-128
Section 14.3: ActionMailer Interceptor
1-129
Section 14.4: Adding Attachments
1-130
Section 14.5: ActionMailer Callbacks
1-131
Section 14.6: Generate a Scheduled Newsletter
1-132
Chapter 15: Rails generate commands
1-133
Section 15.1: Rails Generate Controller
1-134
Section 15.2: Rails Generate Migration
1-135
Section 15.3: Rails Generate Scaold
1-136
Section 15.4: Rails Generate Model
1-137
Chapter 16: Configuration
1-138
Section 16.1: Custom configuration
1-139
Chapter 17: I18n - Internationalization
1-140
Section 17.1: I18n with arguments
1-141
Section 17.2: Translating ActiveRecord model attributes
1-142
Section 17.3: Get locale from HTTP request
1-143
Section 17.4: Pluralization
1-144
Section 17.5: Set locale through requests
1-145
Section 17.6: Use I18n with HTML Tags and Symbols
1-146
Section 17.7: Use I18n in views
1-147
Chapter 18: Using GoogleMaps with Rails
1-148
Section 18.1: Add the google maps javascript tag to the layout header
1-149
Section 18.2: Geocode the model
1-150
Section 18.3: Show addresses on a google map in the profile view
1-151
Section 18.4: Set the markers on the map with javascript
1-152
Section 18.5: Initialize the map using a coee script class
1-153
Section 18.6: Initialize the map markers using a coee script class
1-154
Section 18.7: Auto-zoom a map using a coee script class
1-155
Section 18.8: Exposing the model properties as json
1-156
Chapter 19: File Uploads
1-157
Section 19.1: Single file upload using Carrierwave
1-158
Section 19.2: Nested model - multiple uploads
1-159
Chapter 20: Caching
1-160
Section 20.1: Russian Doll Caching
1-161
Section 20.2: SQL Caching
1-162
Section 20.3: Action caching
1-163
Section 20.4: Fragment caching
1-164
Section 20.5: Page caching
1-165
Section 20.6: HTTP caching
1-166
Chapter 21: ActionController
1-167
Section 21.1: Basic REST Controller
1-168
Section 21.2: Filters
1-169
Section 21.3: Generating a controller
1-170
Section 21.4: Rescuing ActiveRecord::RecordNotFound with redirect_to
1-171
Section 21.5: Display error pages for exceptions
1-172
Section 21.6: Output JSON instead of HTML
1-173
Section 21.7: Controllers (Basic)
1-174
Section 21.8: Parameters
1-175
Section 21.9: Filtering parameters (Basic)
1-176
Section 21.10: Redirecting
1-177
Section 21.11: Using Views
1-178
Chapter 22: Configuration
1-179
Section 22.1: Rails General Configuration
1-180
Section 22.2: Configuring assets
1-181
Section 22.3: Configuring generators
1-182
Section 22.4: Environments in Rails
1-183
Section 22.5: Database Configuration
1-184
Chapter 23: Safe Constantize
1-185
Section 23.1: Successful safe_constantize
1-186
Section 23.2: Unsuccessful safe_constantize
1-187
Chapter 24: Rails 5
1-188
Section 24.1: How to install Ruby on Rails 5 on RVM
1-189
Section 24.2: Creating a Ruby on Rails 5 API
1-190
Chapter 25: Authorization with CanCan
1-191
Section 25.1: Getting started with CanCan
1-192
Section 25.2: Handling large number of abilities
1-193
Section 25.3: Defining abilities
1-194
Section 25.4: Quickly test an ability
1-195
Chapter 26: Mongoid
1-196
Section 26.1: Fields
1-197
Section 26.2: Installation
1-198
Section 26.3: Creating a Model
1-199
Section 26.4: Classic Associations
1-200
Section 26.5: Embedded Associations
1-201
Section 26.6: Database Calls
1-202
Chapter 27: Gems
1-203
Section 27.1: Gemfiles
1-204
Section 27.2: What is a gem?
1-205
Section 27.3: Bundler
1-206
Section 27.4: Gemsets
1-207
Chapter 28: Change default timezone
1-208
Section 28.1: Change Rails timezone AND have Active Record store times in this timezone
1-209
Section 28.2: Change Rails timezone, but continue to have Active Record save in the database in UTC
1-210
Chapter 29: Asset Pipeline
1-211
Section 29.1: Manifest Files and Directives
1-212
Section 29.2: Rake tasks
1-213
Section 29.3: Basic Usage
1-214
Chapter 30: Upgrading Rails
1-215
Section 30.1: Upgrading from Rails 4.2 to Rails 5.0
1-216
Chapter 31: ActiveRecord Locking
1-217
Section 31.1: Optimistic Locking
1-218
Section 31.2: Pessimistic Locking
1-219
Chapter 32: Debugging
1-220
Section 32.1: Debugging Rails Application
1-221
Section 32.2: Debugging Ruby on Rails Quickly + Beginner advice
1-222
Section 32.3: Debugging ruby-on-rails application with pry
1-223
Section 32.4: Debugging in your IDE
1-224
Chapter 33: Configure Angular with Rails
1-225
Section 33.1: Angular with Rails 101
1-226
Chapter 34: Rails logger
1-227
Section 34.1: Rails.logger
1-228
Chapter 35: Prawn PDF
1-229
Section 35.1: Advanced Example
1-230
Section 35.2: Basic Example
1-231
Chapter 36: Rails API
1-232
Section 36.1: Creating an API-only application
1-233
Chapter 37: Deploying a Rails app on Heroku
1-234
Section 37.1: Deploying your application
1-235
Section 37.2: Managing Production and staging environments for a Heroku
1-236
Chapter 38: ActiveSupport
1-237
Section 38.1: Core Extensions: String Access
1-238
Section 38.2: Core Extensions: String to Date/Time Conversion
1-239
Section 38.3: Core Extensions: String Exclusion
1-240
Section 38.4: Core Extensions: String Filters
1-241
Section 38.5: Core Extensions: String Inflection
1-242
Chapter 39: Form Helpers
1-243
Section 39.1: Creating a search form
1-244
Section 39.2: Dropdown
1-245
Section 39.3: Helpers for form elements
1-246
Chapter 40: ActiveRecord Transactions
1-247
Section 40.1: Basic example
1-248
Section 40.2: Dierent ActiveRecord classes in a single transaction
1-249
Section 40.3: Multiple database connections
1-250
Section 40.4: save and destroy are automatically wrapped in a transaction
1-251
Section 40.5: Callbacks
1-252
Section 40.6: Rolling back a transaction
1-253
Chapter 41: RSpec and Ruby on Rails
1-254
Section 41.1: Installing RSpec
1-255
Chapter 42: Decorator pattern
1-256
Section 42.1: Decorating a Model using Draper
1-257
Section 42.2: Decorating a Model using SimpleDelegator
1-258
Chapter 43: Elasticsearch
1-259
Section 43.1: Searchkick
1-260
Section 43.2: Installation and testing
1-261
Section 43.3: Setting up tools for development
1-262
Section 43.4: Introduction
1-263
Chapter 44: React with Rails using react-rails gem
1-264
Section 44.1: React installation for Rails using rails_react gem
1-265
Section 44.2: Using react_rails within your application