Page
1
(This page has no text content)
Page
2
Build A SaaS App in Rails 7 Rob Race This book is for sale at http://leanpub.com/buildasaasappinrails7 This version was published on 2023-09-15 This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do. © 2022 - 2023 Rob Race
Page
3
Contents 1. Ruby on Rails and your First Application . . . . . . . 1 1.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . 1 1.2 Rails Overview . . . . . . . . . . . . . . . . . . . . 2 1.2.1 Rails . . . . . . . . . . . . . . . . . . . . 2 1.2.2 Gems . . . . . . . . . . . . . . . . . . . . 3 1.3 A Sample App to Get You Started . . . . . . . . . 4 1.3.1 Rails Gem . . . . . . . . . . . . . . . . . 4 1.3.2 Installing Rails and Starting a New App 5 1.3.3 Directory Structure . . . . . . . . . . . . 6 1.3.4 Rails Server . . . . . . . . . . . . . . . . 7 1.3.5 Rails Conventions . . . . . . . . . . . . . 10 1.3.6 Hello MVC . . . . . . . . . . . . . . . . . 11 1.4 What did you learn in this chapter? . . . . . . . . 13 1.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 14 2. Testing and You . . . . . . . . . . . . . . . . . . . . . . . 15 2.1 Why Test . . . . . . . . . . . . . . . . . . . . . . . 15 2.2 Testing Frameworks . . . . . . . . . . . . . . . . . 16 2.3 Testing Types . . . . . . . . . . . . . . . . . . . . . 18 2.3.1 Model/Unit Tests . . . . . . . . . . . . . 18 2.3.2 View Tests . . . . . . . . . . . . . . . . . 22 2.3.3 System Tests . . . . . . . . . . . . . . . . 23 2.4 Other Testing Tools . . . . . . . . . . . . . . . . . 24 2.5 CI and You . . . . . . . . . . . . . . . . . . . . . . 25 2.6 What did you learn in this chapter? . . . . . . . . 26
Page
4
CONTENTS 2.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 27 3. Starting your SaaS App . . . . . . . . . . . . . . . . . . . 28 3.1 rails new…for real this time . . . . . . . . . . . . 28 3.1.1 Install PG . . . . . . . . . . . . . . . . . 28 3.1.2 rails new with pg . . . . . . . . . . . . 29 3.1.3 Database Configuration . . . . . . . . . 29 3.2 Git gud enuf . . . . . . . . . . . . . . . . . . . . . . 30 3.2.1 Git Commands . . . . . . . . . . . . . . 31 3.2.2 Git Usage . . . . . . . . . . . . . . . . . . 32 3.3 Gemfile and preferred gems to start . . . . . . . . 34 3.4 Using TailwindCSS . . . . . . . . . . . . . . . . . . 40 3.4.1 First Controller, Views, and Tests . . . . 42 3.4.2 Application layout . . . . . . . . . . . . 46 3.4.3 Turbo . . . . . . . . . . . . . . . . . . . . 54 3.4.4 One more thing… . . . . . . . . . . . . . 54 3.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 55 4. Users are Everything . . . . . . . . . . . . . . . . . . . . 56 4.1 User Model . . . . . . . . . . . . . . . . . . . . . . 57 4.1.1 But first, UUID . . . . . . . . . . . . . . 58 4.1.2 Creating a Users Table . . . . . . . . . . 59 4.1.3 Installing Devise . . . . . . . . . . . . . 63 4.2 Sign in, out, and up . . . . . . . . . . . . . . . . . 68 4.3 User Management . . . . . . . . . . . . . . . . . . 102 4.3.1 User Invites . . . . . . . . . . . . . . . . 103 4.3.2 Managing the Users . . . . . . . . . . . 105 4.3.3 Testing User Management . . . . . . . . 128 4.3.4 CanCanCan . . . . . . . . . . . . . . . . 146 4.4 What did you learn in this chapter? . . . . . . . . 157 4.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 158 5. Business Models and Logic . . . . . . . . . . . . . . . . 159 5.0.1 rails g scaffold . . . . . . . . . . . . . 161 5.0.2 Model . . . . . . . . . . . . . . . . . . . . 163 5.0.3 Controller . . . . . . . . . . . . . . . . . 163
Page
5
CONTENTS 5.0.4 Views . . . . . . . . . . . . . . . . . . . . 166 5.1 Creating The Remaining Business Logic . . . . . 172 5.1.1 Current Date . . . . . . . . . . . . . . . 172 5.1.2 Teams using Has Many Through . . . . 186 5.1.3 Navigating better navigation . . . . . . 228 5.1.4 Tasks with Single Table Inheritance . . 235 5.2 What did you learn in this chapter? . . . . . . . . 283 5.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 283 6. Service Objects . . . . . . . . . . . . . . . . . . . . . . . 285 6.1 What is a Service Object? . . . . . . . . . . . . . . 285 6.1.1 So…a service Object? . . . . . . . . . . . 286 6.2 Building and using a service object in this app . . 292 6.3 More uses for Service Objects . . . . . . . . . . . . 299 6.4 What did you learn in this chapter? . . . . . . . . 307 6.5 Exercise . . . . . . . . . . . . . . . . . . . . . . . . 307 7. Background Jobs, ActiveJob and Sidekiq . . . . . . . . 308 7.1 What is a Background Job, and why use one? . . 308 7.2 Right Tools for the “background” job . . . . . . . 309 7.2.1 ActiveJob . . . . . . . . . . . . . . . . . . 310 7.2.2 Sidekiq . . . . . . . . . . . . . . . . . . . 314 7.2.3 Sneakers . . . . . . . . . . . . . . . . . . 314 7.2.4 SuckerPunch . . . . . . . . . . . . . . . . 315 7.2.5 Other Notable Mentions . . . . . . . . . 315 7.3 Using SideKiq with ActiveJob . . . . . . . . . . . 316 7.4 Other ActiveJob tips and tricks . . . . . . . . . . . 317 7.5 Scheduled Jobs . . . . . . . . . . . . . . . . . . . . 320 7.6 What did you learn in this chapter? . . . . . . . . 331 7.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 332 8. Mailers and You . . . . . . . . . . . . . . . . . . . . . . . 333 8.1 What is a Mailer? . . . . . . . . . . . . . . . . . . . 333 8.2 Using a Mailer in your application . . . . . . . . . 335 8.2.1 Adding a Welcome Email . . . . . . . . 335 8.2.2 Email Recap . . . . . . . . . . . . . . . . 345
Page
6
CONTENTS 8.2.3 Mail in Production . . . . . . . . . . . . 356 8.3 Receiving mail or replies . . . . . . . . . . . . . . 357 8.4 What did you learn in this chapter? . . . . . . . . 373 8.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 374 9. HotWire . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 9.1 What is HotWire? . . . . . . . . . . . . . . . . . . 375 9.1.1 What is Turbo? . . . . . . . . . . . . . . 375 9.2 Using HotWire in your application . . . . . . . . . 376 9.3 Streaming Updates . . . . . . . . . . . . . . . . . . 376 9.3.1 Streaming Standup Create . . . . . . . . 378 9.3.2 Streaming Standup Update . . . . . . . 383 9.3.3 Streaming Standup Removal . . . . . . . 385 9.3.4 Streaming Standup Changes onto Team pages . . . . . . . . . . . . . . . . . . . . 388 9.4 Turbo Frames . . . . . . . . . . . . . . . . . . . . . 417 9.5 What did you learn in this chapter? . . . . . . . . 433 10. Stripe Payments and Subscriptions . . . . . . . . . . . 434 10.1 Stripe . . . . . . . . . . . . . . . . . . . . . . . . . . 434 10.2 Stripe Gem . . . . . . . . . . . . . . . . . . . . . . 435 10.3 Products . . . . . . . . . . . . . . . . . . . . . . . . 437 10.4 New Account; New Subscription . . . . . . . . . . 443 10.4.1 Some Subscription Specs . . . . . . . . . 456 10.5 Stripe’s Billing Portal . . . . . . . . . . . . . . . . 461 10.5.1 Stripe Events . . . . . . . . . . . . . . . . 463 10.6 Checking for an Active Subscription . . . . . . . . 470 10.7 Limits . . . . . . . . . . . . . . . . . . . . . . . . . 476 10.8 What did you learn in this chapter? . . . . . . . . 483 10.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 483 11. Using Third-Party APIs in your Application . . . . . . 484 11.1 Github Integration . . . . . . . . . . . . . . . . . . 485 11.1.1 Github Gems . . . . . . . . . . . . . . . 485 11.1.2 Implementing Account and Github API 486 11.1.3 Granting Access to Github via OAuth . 487
Page
7
CONTENTS 11.1.4 Fetching Data through Github . . . . . 500 11.1.5 Accessing and Handling Github Web- hooks . . . . . . . . . . . . . . . . . . . . 522 11.1.6 Displaying Event Data . . . . . . . . . . 535 11.1.7 Testing the Github Integration . . . . . 546 11.2 Analytics: What are they good for? . . . . . . . . 576 11.2.1 Choices . . . . . . . . . . . . . . . . . . . 577 11.2.2 Implementing and Sending events . . . 578 11.3 What did you learn in this chapter? . . . . . . . . 585 11.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 585 12. Speeding up Rails . . . . . . . . . . . . . . . . . . . . . . 587 12.1 What Slows Rails Down? . . . . . . . . . . . . . . 587 12.1.1 N + 1 Queries . . . . . . . . . . . . . . . 589 12.1.2 Queries without indices . . . . . . . . . 591 12.1.3 Pagination . . . . . . . . . . . . . . . . . 592 12.1.4 Gzip . . . . . . . . . . . . . . . . . . . . 601 12.1.5 Caching . . . . . . . . . . . . . . . . . . 602 12.1.6 How to Implement Caching . . . . . . . 604 12.2 What did you learn in this chapter? . . . . . . . . 610 13. Deployments . . . . . . . . . . . . . . . . . . . . . . . . . 612 13.1 There are many choices . . . . . . . . . . . . . . . 612 13.2 Prepare application . . . . . . . . . . . . . . . . . . 612 13.3 Deploy with Heroku . . . . . . . . . . . . . . . . . 614 14. A Few Other Rails Tools . . . . . . . . . . . . . . . . . . 617 14.1 Async Queries . . . . . . . . . . . . . . . . . . . . 617 14.2 Active Record Encryption . . . . . . . . . . . . . . 619
Page
8
1. Ruby on Rails and your First Application In this chapter, we will go over a little bit of the history of Rails and its benefit to you and some of the Rails basics. Ruby on Rails is a web framework that had its humble beginning in 2004. In an upcoming chapter, you will build your example SaaS app, an Agile/Scrum Daily Standup Tracker. You should be able to deviate from the example app at any time with your business idea. This book attempts to present concepts in a way that transcends any business logic or differentiations you may have. 1.1 Prerequisites Knowing a few of the following concepts will make the best use of this book. You may be able to work your way through the book without all or any of them. Though you may benefit from having an understanding of the following • HTML and CSS: You should have a basic understanding of HTML and CSS, and we are using the Bootstrap HTML/CSS framework. Bootstrap abstracts away the painful parts of HTML/CSS/layouts. Any knowledge of HTML/CSS will help you navigate yourway through changes or any customization you would like to do. • SQL: A basic understanding of databases and SQL will help you understand database interactions in Rails, including how you are querying the database or database abstractions.
Page
9
Ruby on Rails and your First Application 2 • Ruby: This book will walk you through building an app with Rails. A basic understanding of Ruby (or another pro- gramming language) will help you get the most use of all the chapters in this book. In addition, you can grasp the examples throughout the book if you understand variables, conditionals, loops, and methods within the Ruby language. • Linux: Having a Mac or Linux machine is the most accessible path to installing Ruby, Rails, and other packages used in developing an app. While it is possible to develop Rails on a Windows machine, it is not the most documented or utilized operating system for developers. Thus, usingWindowsmeans you may experience more setup issues and less help in the form of recorded fixes across the internet. However, I’ll point out some excellent Windows-based variations via third-party blog posts as the need arises. 1.2 Rails Overview 1.2.1 Rails David Heinemeier Hansson created Rails as he intended to create a simple *Convention over Configuration Framework*. Many web frameworks in the early 2000s would have extensive systems of configuration and needed many files to get your web applications up and running. David, finding this needless, designed Rails to have deep-rooted conventions making setting up and changing Rails apps a breeze. Ruby on Rails is open source, meaning it is accessible to end-users and maintained by contributors worldwide. Powering Rails is the Ruby programming language. It is considered by many as one of the most pleasurable languages to program in, with its simplistic, expressive nature and its modularity.
Page
10
Ruby on Rails and your First Application 3 Most times, you’ll be wondering how it can be so easy — adding another resource from the database, through RESTful routes and templated views, for example. New feature additions to Rails have slowed down in recent years. This pace lends itself to Rails’ now stable nature. The Rails core team is still keeping pace with other web frameworks and languages in areas such as WebSockets and javascript package management. When you are stuck in Rails, you will be hard-pressed not to find an answer or support channel due to its longevity and large community. You’ll often find an answer in the vast database of Questions and Answers on Stack Overflow. Otherwise, you can browse issue tracking in the Rails Github repositories. Lastly, you can find in-depth helpwith over ten years of blog posts and tutorials on copious blogging platforms or plenty of books! Most times, you can be on your way to solving your issue within seconds just by Googling the problem or exception message. 1.2.2 Gems Gems are Ruby’s self-contained packages of code. Gems are solving or collapsing logical programmatic problems. For instance, a gem called Devise helps create a near end-to-end authentication system. Another gem, Puma, provides you with a threaded HTTP server to serve your web application. Puma provides a local server as you develop and on a server in a production environment. There are thousands upon thousands of gems out there! Most gems are designed to help with most problems you encounter and have been vetted and used by millions in the open-source community.
Page
11
Ruby on Rails and your First Application 4 1.3 A Sample App to Get You Started 1.3.1 Rails Gem By default, not all systems have Rails installed. Most times, if a system does have a system-level version of Ruby, it is older than you would like for current development. Let’s go over how you can install a recent version of Ruby, manage multiple Rails versions, and group gems to have a cleaner separation of gem versions per project. The instructions for this tutorial address development on OSX and should work on almost any Unix-based system(OSX, Linux, etc.). I am deferring to a Rails 5 install blog post for Windows (http://blog.teamtreehouse.com/installing-rails-5-windows¹) You can use many different tools to manage ruby versions, such as RVM, RBenv, or Chruby. I am still a fan of RVM after all these years. I find it easy for beginners to grok and simple to maneuver once you get it. I recommend visiting the RMV website (https://rvm.io/ ²). Upon the browser rendering the RVM website, you find two simple bash commands you can use to install RVM. I opted not to print the commands here as 1) a digital security measure and 2) they may change as time goes on. Once installed, we can begin installing the latest version of Ruby. rvm list known This command lists the current versions of Ruby available to install. There may be a lot on the list, but we can focus on the primary interpreter MRI plus the latest version(3.0.x as of writing). Now, the command to install: ¹http://blog.teamtreehouse.com/installing-rails-5-windows ²https://rvm.io/
Page
12
Ruby on Rails and your First Application 5 rvm install 3.0.4 Now sit back or grab a coffee as the installation can take anywhere from 1 to many minutes to complete. This wait is based on Ruby package availability, system speed, and many other factors. Once the gems are installed, you can now set up a gemset. A gemset is a way to group installed gems into a particular RVM-based folder. Gemsets keep different projects and their various versions of gems from interfering with each other. Although with Bundler, this isn’t a huge issue, it doesn’t hurt to take the extra step and keep your gems tidy. Additionally, this command instructs RVM to use the recently installed version of Ruby at the same time: rvm use 3.0.4@sample_app --create The extra --create flag tells RVM to create the gemset if it doesn’t exist(which it doesn’t). Now that we finally have our Ruby and Gemsets in order, we can install Rails. We are starting a new sample project to show you the basics of a new Rails app. Later we rerun this command for the SaaS app’s creation. Please refer to the RVM documentation if you want to dig deeper into any other features of RVM past the basics in this chapter. 1.3.2 Installing Rails and Starting a New App Now that we have Ruby installed and the gemset ready to go from the last portion of this chapter, we can now install Rails. We are installing version 7.0.2 and continue to use this version to keep results consistent throughout the book. It may not be all smooth sailing when installing Ruby or specific Ruby gems. For instance, when trying to install rails on ruby 3.0 on my system from a clean slate, I ran into OpenSSL issues. I also ran
Page
13
Ruby on Rails and your First Application 6 into a problemwith libraries needed for a gem called Nokogiri(used for HTML parsing in rails). It is somewhat impossible to predict issues you may see during installation with many Ruby versions, Rails versions, operating systems, and particular versions. Thus, I recommend you Google the error + the operating system + operating system version. You will usually have an answer within a couple of results and, most times, the first StackOverflow link you find. Anyway, on with the installation: gem install rails -v 7.0.2 Assuming your install finishes without error or after you solve all install issues, you can run the following command to create a new application. rails new sample_app After this command completes, your rails app is installed. Rails first installs the needed default gems, default commands, and file watchers. Also, note that the rails new command has many more flags and options, which you can read by typing the following. rails new --help 1.3.3 Directory Structure Rails come with a default directory structure to auto-load many files and folders. This organization of files may seem magical, but it is Rails’ strong convention over configuration at work. This structure makes it easy to get started with a base application. In fact, after going over the directory structure, let’s fire up the Rails application you created. Then even make a minor modification to get your own “Hello World” response! Anyway, onwards and upwards. Let’s go over the directories!
Page
14
Ruby on Rails and your First Application 7 Folder Use app/ This is the primary parent folder of your application. app/assets App-specific stylesheets and images app/channels Files to handle WebSocket channel negotiations app/controllers Rails controller files app/helpers Helper methods for controllers and more often view files app/jobs Files for your background jobs app/javascript Where your app-specific javascript goes app/mailers This folder will hold mailer setup files app/models Model files that represent table database rows app/views This is where your templates and markup will live bin/ This is where some rails command files exist config/ This will house configuration files db/ Database and database related files lib/ Library module files that are not part of the app itself log/ Rails creates log files, and they are in this folder public/ Here, you can put static files such as favicons test/(or spec/) All your test folders and files vendor/ Here, you can put third party javascript, stylesheets, or fonts 1.3.4 Rails Server You can start a brand new project’s application immediately with no further changes needed. This functionality is provided in many frameworks as a way to show you, yes, your install worked! As a note, staying with an assumption of OSX in this book, you will use the Unix-based cd command to change directories. This
Page
15
Ruby on Rails and your First Application 8 command should work in many other shells on Windows and virtually all Linux systems. cd sample_app bundle install rails server That command moves you into the applications directory and fires up Rails’ development server on port 3000. Go ahead and go to http://localhost:3000³, and you should see a welcome page Let’s not stop there, however! What is any programming book without a “Hello World” example? We will be changing two files to make this work. I will paste in the entirety of these two files, and you can use your text editor of choice(Sublime Text, Atom, vim, etc.). ³http://localhost:3000
Page
16
Ruby on Rails and your First Application 9 class ApplicationController < ActionController::Base protect_from_forgery with: :exception def awesome_action render html: "<h1>Hello, world!</h1>".html_safe end end The addition to the file is the method ‘awesome_action’. When a request comes in the app that is directed to the awesome_action in the ApplicationController, it renders an HTML string that says “Hello, world!”. The additional method at the end of the file ensures we pass the string through to the response with escaped HTML instead of the literal string. It is thus allowing the browser to display the text as a heading. As a small note, actions are very rarely assigned or defined in the ApplicationController file. Instead, this controller is used for methods or functionality that extends to most other controllers. I will explain and show this in future chapters. So, how do we tell the Rails app to direct the request to the root address of our new awesome_action? Well, we edit the routes file: Rails.application.routes.draw do root to: 'application#awesome_action' end The routes file handles directing incoming HTTPS requests. They are directed to the responsible controller and action based on path, content type, and HTTPmethod type. Further, in the book, you will see more Rails conventions to make this quick and painless for the usual REST routes and actions.
Page
17
Ruby on Rails and your First Application 10 The router uses the controller_name#action with multiple meth- ods and parameters. Setting the root route is no different. Here the route says, “set the root path to the ApplicationController and the awesome_action action”. Then, using the previously explained controller code tells the browser to render our HTML message! So, if you head to http://localhost:3000⁴ again, you should see our new message to the world! 1.3.5 Rails Conventions Rails follows an MVC convention. This acronym stands for Model- View-Controller. A model is a Ruby class that interfaces with the database processes validations and can hold some extra business logic. A view is the markup file or template in Rails. The View is typically an HTML templating engine but can be other files such as javascript files with embedded Ruby code or JSON files. Last is the controller. The controller, as described earlier, holds the actions as an HTTP request routes through the application. Controllers are unique because they almost always interface with both a Model and a View in a Controller’s action. Models: Models interface with the database through the ActiveRecord ORM(Object Relational Mapping). For example, you would have a Model class such as User, which represents the mapping between the databases’ users table and the objects in Rails. Models also have a built-in validation framework where you can validate uniqueness, presence, regular expressions, and much more. Each Model object represents a record in the database, for example. ⁴http://localhost:3000
Page
18
Ruby on Rails and your First Application 11 User.find(42) #=> {id: 42, name: "John"} User.create({name: "James"}) Rails models using ActiveRecord also have a ton of convenience through a convention. Such as referenced associations (belongs_to, has_many, etc.) and callbacks(before_create, after_save, etc.). Controllers: Controllers are vital but straightforward. As a request comes through the router, it is routed, and an action method inside a controller glues the request to the model (database), View (markup), and sometimes other business logic (background tasks, services, etc.). Controllers are also responsible for handling abstract but needed logic such as sessions, authorizations, errors, or redirects. One important thing to note is the use of instance variables in actions. This detail allows values set in the controller to be accessed within the View. Meaning a database record looked up through a model instance gets saved to an instance variable that is accessible in the View. View: Views are pretty straightforward. Nearly every time you need to deal with a view, it is an HTML-based template. By default, Rails uses the ERB format for representing markup with embedded Ruby. <h1><%= @user.name %></h1> Yet, the view file can be other types of markup/template, such as Javascript, CSS, JSON, XML, CSV, and more! 1.3.6 Hello MVC Let’s combine the last two sections into a very MVC like Hello World. We will need a Model, a new Controller, and a View. We
Page
19
Ruby on Rails and your First Application 12 can start with the model. For simplicity, we will create a plain old Ruby class that we can instantiate with a name attribute. class User attr_reader :name def initialize(name='Rob') @name = name end end If you are unfamiliar with Ruby classes, initialize is called when- ever a class instantiates a new object (e.g., User.new). While attr_- reader (and the later @name = name) sets up a getter method (mean- ing you can use user.name to get the name value) and name='Rob' to set a default value. You can read a longer overview of Ruby classes here⁵. Next, we can create the new controller. Again, this looks very close to the sample action we added earlier but in a new file this time. class StaticController < ApplicationController def hello_mvc @user = User.new end end The only new syntax here is the @user = User.new line that creates an object used in the View we are about to make. You may wonder why there is an @ in front of the variable. In Rails, an instance variable (one prefixed with @) is available throughout the request and added to the View as a controller’s action renders. Thus, we will be able to use @user.name in the View. ⁵http://rubylearning.com/satishtalim/writing_our_own_class_in_ruby.html
Page
20
Ruby on Rails and your First Application 13 As mentioned before, Rails uses ERB for the View templating. It is straightforward to use by starting with standard HTML and adding Ruby. Here is the view of our sample app. <h1> Hello <%= @user.name %> </h1> The last part of tying all of this together is to update the routes.rb file to use the new MVC code path we just created! Rails.application.routes.draw do root to: 'static#hello_mvc' end If you still do not have your Rails server running, head back to your terminal, type rails server, and go to your localhost address. You should see Hello Rob in an H1 tag. Since the model object takes a name parameter, you can change the line in the controller to any name you would like, such as @user = User.new('Bob'), reload the page in your browser, and see the new name. Hopefully, this little example we just made showcases how easy it is to build with Rails. It gets even more comfortable as we go through the book and see how many Rails conventions make the process even quicker. 1.4 What did you learn in this chapter? • You learned about the origins of Ruby on Rails and its intentions. • You learned what gems are and why they are used.