Ruby on Rails a full stack MBC web
framework famous for powering some of
the most successful internet startups of
the last 20 years it was created in 2004
by David hanm Hansen to give developers
a way to build largescale web
applications quickly with the Ruby
programming language it exploded in
popularity among the Silicon Valley Tech
bro scene and helped launch unicorn
startups like Airbnb Shopify and GitHub
just to name a few its underlying
architecture is based on the model view
controller pattern a model contains the
business Logic for your database rails
has a built-in om called active record
that can easily model relationships in a
SQL database on the other end we have
the view for presentation logic which
includes a mix of HTML CSS and embedded
Ruby which displays Dynamic data quered
from the back end this data is made
available by the controller which sits
in the middle it takes the incoming HTTP
request from the user it fetches data
from the model and finally responds with
HTML or Json this pattern actually
predates the web itself but rails makes
it extremely easy to implement by
following a highly opinionated and
controversial Doctrine which includes
nine Commandments like convention over
configuration and exalt beautiful code
let's build a full stack application
right now by installing Ruby rails and
SQL light now run the rails new command
to scaffold out a new project from here
you'll notice a gem file to install
dependencies in Ruby a rake file which
is like a make file in C to run a task
but the bulk of your code will be
written in the app directory in addition
to models views and controllers you'll
also notice mailers for transaction
actional email jobs for background work
and channels for real-time connections
via websockets and we have a JavaScript
directory configured with hot wire
allowing you to build a highly
interactive front end without the
unnecessary complexity of a JavaScript
component framework rails also has an
extremely powerful CLI generate will
build your models ussing controllers or
do everything all at once with scaffold
we give our model a name which is plural
by convention then provide some fields
and types we might use in the database
this command creates a bunch of files
but let's go ahead and run rake to
migrate the database then rail server to
run it locally congratulations you just
built a piece of crud a full stack app
that can create read update and delete
your database model in the browser how
did we do that so fast at first the
routes RB file mapped a set of URLs to
our controller automagically created by
this resources method when a user
navigates to one of those routes it
triggers a controller action like index
will'll fetch all the records from the
database by calling the all method which
is provided automatically by the model
we could also perform data validations
here and do joins with other models now
the controller created an instance
variable which we can access directly in
the html. embedded Ruby file here we
have each row in the database as a rubby
object which we can Loop over with each
to display it in the front end UI this
has been rails in 100 seconds but if you
really want to learn how to build cool
web apps it's far more important to
learn how to problem solve like a
programmer you can start making that
happen for free thanks to this video
sponsor brilliant web Frameworks come
and go but problem solving is a skill
that you keep forever Brilliance
platform will introduce you to essential
Pro programming Concepts but most
importantly the Hands-On exercises will
develop your brain to recognize and
solve complex problems that developers
need to overcome on a daily basis best
of all every lesson is concise and
rewarding but by investing just a few
minutes each day you'll develop habits
that can level up your programming
skills for the rest of your life and you
can do it anywhere even from your phone
to try everything brilliant has to offer
for free for 30 days visit brilliant.org
fireship or scan this QR code for 20%
off their premium annual subscription
thanks for watching and I will see you
in the next one