00:00:16.960
Hello everyone.
00:00:18.960
So u with each opportunity to speak at
00:00:22.560
the conferences you always have that a
00:00:24.720
bit of anxiety bit of a eagerness or a
00:00:28.560
consistent thought going in your back of
00:00:30.320
the head thinking about oh I can add
00:00:32.239
this I can add that u maybe I can think
00:00:34.559
of this joke I can think of that joke
00:00:36.800
and once your talk is over then you are
00:00:38.640
relieved you are free to enjoy your rest
00:00:40.399
of the conferences this time around
00:00:43.280
after this talk it will happen for me
00:00:45.280
for the rest of the conference which is
00:00:47.120
just a one keynote But yeah, why not?
00:00:50.320
So, here is my talk, the real story. Two
00:00:52.800
decades of a design and decisions. Yeah.
00:00:55.760
Uh that's my Twitter handle, RTDP. Uh
00:00:58.719
it's also uh Ruby social handle RTDP.
00:01:02.559
Um it's a it's a short form for my name,
00:01:04.640
but many of my friends these days call
00:01:06.720
it as a rails through decades of
00:01:09.119
pleasure. Um standing for RTDP. Yeah.
00:01:13.360
And as as um we talked about in it my
00:01:16.640
intro about me um I I am a digital
00:01:19.200
nomad. I have been to many places. These
00:01:21.360
are some of the pictures that I liked
00:01:23.040
from all of my travels. Uh there are
00:01:25.600
many places I have been to in India and
00:01:28.080
uh Philadelphia is my like 15th city in
00:01:30.720
the US as well. So
00:01:33.280
um and I run a company called Betagraph
00:01:35.840
Technologies. We work mainly in a
00:01:37.200
consulting u ruby on rails applications.
00:01:40.720
uh when it comes to learning new things
00:01:42.720
I find that the technical talks and the
00:01:44.560
conference talk is a really good source
00:01:46.399
and I'm always look out uh for finding
00:01:49.040
the good ideas. So the discovery I
00:01:51.360
sometimes feel that is not a a problem
00:01:53.360
that's been solved when it comes to
00:01:54.880
finding the good tech talks that you can
00:01:56.880
watch and then learn from which is why I
00:01:59.759
created this website called as a tech
00:02:01.280
talks um the domain is a tech talks.io
00:02:04.960
io and this is how it looks. So you can
00:02:08.479
go there explore multiple uh talks um
00:02:11.680
interesting ones. Uh we are working on
00:02:13.680
the algorithms to make sure that there
00:02:15.520
are some trending talks that could come
00:02:17.920
up based on what the community is
00:02:19.760
currently time. Okay. And I also have
00:02:24.000
the stickers. Um so find me after the
00:02:27.040
talk for that. So with that let's get
00:02:29.599
started. Uh the Rails story. Um this is
00:02:33.200
more of divided into the two sections.
00:02:35.040
First is the origins where we have few
00:02:38.000
why stories and then apart from that we
00:02:41.360
will go into few of the general stories.
00:02:43.280
The reason I feel that why is important
00:02:45.519
is because many of times when you are
00:02:48.000
trying to learn something trying to
00:02:49.360
understand something or even trying to
00:02:51.040
use it in day-to-day life knowing why
00:02:53.360
behind the things provides you with a
00:02:55.280
better context better understanding. Uh
00:02:57.519
which is why I feel it is important to
00:02:59.040
know the why. Yeah.
00:03:01.440
So the first why that we will explore is
00:03:03.599
why Ruby and for that we will have to
00:03:06.159
explore uh go back in the time and
00:03:10.239
understand what was the situation. So
00:03:12.400
you all know this guy right uh needs no
00:03:14.879
introduction and the time period like
00:03:17.519
this is the oldest photo that I could
00:03:19.360
find of uh DHH on the internet. uh and
00:03:23.200
this is the time 2003 2004 um he was
00:03:26.560
working with 37 signals which is a
00:03:28.319
consulting company and a lot of the
00:03:30.000
clients that he has were working on the
00:03:32.080
PHP and Java so all of these clients
00:03:33.840
used to come with their uh preference
00:03:36.000
for the language or a stack and that is
00:03:38.640
the reason he has to stick with the PHP
00:03:40.400
and Java itself there wasn't any
00:03:41.840
alternatives now both these options had
00:03:44.480
their some pluses and then lots of cons
00:03:46.879
like for example in case of a Java uh
00:03:49.200
the framework of choice back then was
00:03:51.120
Apache Struts And uh it had quite a lot
00:03:53.680
of issues like XML help. We will talk
00:03:55.519
about that in a while. And when it comes
00:03:57.439
to the PHP, it was more ubiquitous and
00:03:59.760
accessible. But then that accessibility
00:04:02.000
came at the cost and that cost was the
00:04:04.480
structure. So the app that were built
00:04:07.280
with the PHP were difficult to maintain.
00:04:09.760
There were a lot of spaghetti code and
00:04:11.840
when it comes to the business logic and
00:04:13.360
HTML both of them were interwined and
00:04:16.160
those were the problems. So during this
00:04:18.479
time uh DHH was very much
00:04:22.160
following the people like Martin Fowler
00:04:24.000
and Dave Thomas. He used to consider
00:04:25.600
them as a thought leadersh and he was
00:04:27.919
influenced by their writings and during
00:04:30.639
these writings many times to explain
00:04:32.639
some of the concepts they would stick
00:04:35.040
with the Ruby as a programming language
00:04:37.040
of a choice and that's how DH got
00:04:40.080
introduced to the Ruby and that's how he
00:04:41.759
started playing around with Adobe but
00:04:43.520
then the big thing happened when uh base
00:04:46.800
camp a project that 37 signals was
00:04:49.440
building uh was being uh built with that
00:04:53.199
what came is first time DHS did not had
00:04:56.240
any um restrictions as to which language
00:04:59.360
to choose. he was free to choose
00:05:00.800
whatever he wants. And with that what he
00:05:03.919
thought was hey there are like I I just
00:05:07.120
took this quote as is from one of his uh
00:05:09.199
older podcasts that uh there are all
00:05:11.199
these very smart people who I look up to
00:05:13.120
and have learned a lot from and if they
00:05:16.000
pick Ruby when they are free to pick
00:05:17.600
then why wouldn't I give the try uh and
00:05:19.759
a chance uh when I am free to pick and
00:05:22.080
that's how he decided to go for it right
00:05:24.800
and this is a time uh in which he was at
00:05:28.720
one of the Ruby conferences where there
00:05:30.400
were about only 40 42 people and one of
00:05:34.320
the speaker asked how many of these uh
00:05:36.479
how many of you are actually using Ruby
00:05:38.479
for professional work or you are getting
00:05:40.720
paid for writing Ruby and there were
00:05:42.800
only two people who said that they are
00:05:44.960
doing that and one of that was DH and DH
00:05:47.039
was working on the base camp and was
00:05:48.400
getting paid for that. So those were the
00:05:50.160
days and it was so unconventional to
00:05:52.479
choose a language like Ruby but still he
00:05:54.720
decided to go go ahead with that.
00:05:57.680
So the reason he felt that it was
00:05:59.759
important for him was he felt that Ruby
00:06:01.680
is an exceptional language. Again one of
00:06:03.680
the quote from uh his podcasts from that
00:06:06.479
time which is one that transitioned me
00:06:09.280
from being a programmer who programmed
00:06:10.960
to get the programs to being a
00:06:12.560
programmer who programmed for the own
00:06:14.240
sake of the programs and that is
00:06:17.919
important. Uh yeah so I was thinking
00:06:23.199
along that line what are some of the
00:06:25.199
things that I could find where the Ruby
00:06:28.319
uh shows up its own happiness for the
00:06:31.360
developers or programmer happiness as
00:06:32.880
one of the priorities and this is an
00:06:34.800
example I could find. So here is a
00:06:36.720
comparison between let's say Python
00:06:38.400
versus Ruby where in in Python uh the
00:06:41.600
example first one we will look at it is
00:06:43.120
Ruby where you are in an interactive
00:06:44.639
console you are trying out the IRB and
00:06:46.560
then you type quit and then you can come
00:06:48.560
out of it or if you go into the IRB
00:06:50.240
admin and type uh exit then you can also
00:06:52.880
come back out of it but if you try to do
00:06:55.759
the same with the Python
00:06:57.919
type exit Python knows what you're
00:07:00.560
trying to do but then it will still ask
00:07:02.560
you to type exit along with the brackets
00:07:05.039
to exit. it out of that console. So that
00:07:06.960
is the difference between Python versus
00:07:08.400
Ruby wherein Ruby thinks and says that
00:07:11.280
um hey how can I help you versus Python
00:07:13.599
is like hm have you read the manual. So
00:07:16.639
that's is the philosophical difference
00:07:18.960
between these two languages and when it
00:07:21.360
comes to uh choosing the Ruby it is also
00:07:23.919
about how does a programmer feel about
00:07:25.599
it. So many a times when languages are
00:07:27.919
getting designed a lot of those get
00:07:30.400
optimized for the machines and whenever
00:07:32.560
there is a choice or whenever there is a
00:07:35.280
uh decision that is putting a human and
00:07:38.240
a machine in front of each other a lot
00:07:40.240
of times what gets chosen and optimized
00:07:42.560
for is machines instead of humans and
00:07:45.039
that's why DH felt that Ruby is a
00:07:47.039
programming language that is rather
00:07:48.319
optimizing for the humans for their
00:07:50.240
readability for their happiness and
00:07:52.080
that's why he chose Ruby to build the
00:07:55.039
basecam application. So that tells us
00:07:58.000
why Ruby. The next question is then why
00:08:00.240
Rails? U so when building the base camp
00:08:02.960
web application with Ruby uh he realized
00:08:04.879
that no tooling is available back then.
00:08:07.440
A lot of things that he used to be very
00:08:09.520
familiar and uh use with let's say a
00:08:12.160
tool a language like a PHP or a Java
00:08:14.560
weren't available for Ruby programming
00:08:16.560
language. So he had to write all of
00:08:18.160
those today. And let's take an example
00:08:20.879
that if you are to write a web
00:08:23.360
application with Ruby without using
00:08:25.120
Rails, you will at least start with
00:08:26.879
something like a rake, right? Uh now
00:08:29.199
imagine the days when the rake wasn't
00:08:30.720
even there. So he built all this tooling
00:08:33.839
and then the base camp application got
00:08:35.440
completed and then he was enjoying quite
00:08:37.360
a lot. So again quoting him one more
00:08:39.760
time, he was saying that I'm having so
00:08:41.760
much fun programming in Ruby than I ever
00:08:43.839
was in Java or PHP. uh and it would be
00:08:46.399
so awesome if the other people could
00:08:48.399
also have that same experience and that
00:08:50.560
thinking led him to extract the ruby on
00:08:53.200
rails as a framework from the base camp
00:08:54.880
as an application. I remember uh
00:08:57.200
listening to him in one of the podcast
00:08:58.800
and uh the question that was asked to
00:09:00.560
him was what is the best way to build a
00:09:02.720
framework and was it's better not to try
00:09:06.480
if you go for building a framework it
00:09:08.240
won't work but rather if you build an
00:09:09.839
application and try to extract the
00:09:11.120
framework out of it maybe that's your
00:09:12.880
best bet to build a good framework.
00:09:15.600
So he always considered open source to
00:09:17.440
be a really good idea and always felt
00:09:19.760
obliged to contribute back and that's
00:09:21.680
how the uh framework got extracted out
00:09:24.240
of the base camp code.
00:09:26.560
Um so with that there are a couple of
00:09:29.680
things that happened. So it made it
00:09:31.120
possible for the other Ruby developers
00:09:33.040
to use uh Ruby for writing the
00:09:35.920
professional code because otherwise if
00:09:38.080
you think uh if he had all those issues
00:09:40.560
of building the base tools to build a
00:09:42.880
web application into Rails then everyone
00:09:45.360
else who was involved would also have to
00:09:47.200
do that. So for developers to enjoy the
00:09:49.200
Ruby it wasn't possible because if you
00:09:51.120
are getting paid to write the code you
00:09:53.040
don't necessarily have the time to build
00:09:54.560
the framework also along with your
00:09:56.000
application and that's why he decided to
00:09:57.760
open source it so that everyone can
00:09:59.440
benefit out of it. Uh this this also
00:10:02.480
provided a kind of a jump start to pick
00:10:04.320
the Ruby for everyone else.
00:10:07.440
Um so this is a quote that I find very
00:10:10.160
relatable at this stage of a discussion.
00:10:12.399
It is something that is present in the
00:10:14.079
rails doctrine written by the DH which
00:10:16.640
says Ruby has been designed with the
00:10:18.320
principle of least surprise least
00:10:20.480
surprise to the maths of course and the
00:10:22.560
rails has been designed with the
00:10:23.760
principle of bigger smile for DH. Yeah.
00:10:28.079
And and that gets into a nice story
00:10:31.519
about this particular method that we
00:10:33.360
have uh in Ruby in Rails to be precise
00:10:36.399
which is array.42. So it happened that
00:10:39.760
once I was debugging something uh with
00:10:42.000
an application let's say with the
00:10:43.279
transactions and I went to the rails
00:10:45.279
console uh I wanted to have a look at
00:10:46.880
today's transactions. So I ran a query
00:10:49.200
got couple of transactions into an array
00:10:51.120
and then I was trying to go through one
00:10:52.720
by one uh and then very easy and obvious
00:10:56.079
method to go through content that is
00:10:58.240
there in the array is to call array do
00:11:00.320
first array dot second arrow dot last
00:11:02.160
array dot third fourth right and I was
00:11:04.240
wondering okay how many such methods
00:11:07.200
that we have available can I do array
00:11:09.120
dot 999 maybe error dot50 is it possible
00:11:12.240
so that's when I started digging deeper
00:11:14.000
into this particular part and then what
00:11:15.519
I realized was it is available from
00:11:17.680
arrow dot first until array do 5th.
00:11:19.920
Arrow dot first and arrow do.los being
00:11:21.839
part of the Ruby core library itself.
00:11:23.839
While uh array dot second to arrow fifth
00:11:27.040
is something that is provided from the
00:11:28.560
active support. And when these methods
00:11:31.600
were added for the very first time into
00:11:33.360
the Rails um uh standard library, a
00:11:37.680
discussion happened on uh Reddit and the
00:11:40.720
discussion uh went along the lines that
00:11:43.279
why someone would make their public API
00:11:47.440
so much bigger. It is not optimized. It
00:11:50.560
is very bad practice to keep on writing
00:11:52.640
such method even when you have indexed
00:11:56.240
way of accessing the elements from the
00:11:57.920
array. So you can do array and then
00:11:59.600
brackets and then you can pass on the
00:12:01.920
index like 0 1 2 or whatever and then
00:12:03.839
get that element. So why these methods
00:12:05.519
are being written and that is I feel is
00:12:08.240
the philosophical difference between
00:12:10.079
being too practical and machineoriented
00:12:12.320
versus being on the side of uh the
00:12:14.800
happiness. So at the end of that
00:12:17.040
discussion and when all of this went
00:12:19.120
viral uh DHS had created a pull request
00:12:22.079
onto the rails application saying that I
00:12:24.000
have worked on it and optimized and then
00:12:25.839
only this method is what is required
00:12:27.360
which is array.42. So if you check
00:12:29.920
within the rails arrays arrow.42 is a
00:12:32.079
real method that actually works and if
00:12:33.920
you look into the rails codebase uh it
00:12:36.320
is there with a quote saying that it is
00:12:38.880
for the Reddit users. Yeah.
00:12:43.200
And then this is the second thing. Uh
00:12:45.680
user.find by first name, last name and
00:12:47.920
email. So for those of you who don't
00:12:50.240
know what this is about, uh this is
00:12:52.079
dynamic finders. It used to be there in
00:12:53.760
the rails. And one of the thing that I
00:12:55.440
really loved when I initially started
00:12:57.600
and I remember telling about this thing
00:12:59.600
to the others who were not using the
00:13:01.040
rails and how cool rails is wherein
00:13:03.519
what's happening here is basically let's
00:13:05.040
say you have a table called and there
00:13:07.200
are multiple columns like first name,
00:13:09.040
last name and email. And now today if
00:13:11.839
you have to search within this then what
00:13:14.160
you would go with is user.ware and then
00:13:16.240
you pass on a hash with first name, last
00:13:17.920
name and email uh being the keys and
00:13:20.240
whatever the values that you're looking
00:13:21.519
for. But back then we had these dynamic
00:13:23.680
finders wherein what used to happen was
00:13:25.440
uh you can build these methods find by
00:13:27.600
first name uh and last name and email.
00:13:29.839
Okay, I missed an and there but it could
00:13:31.600
also be find by first name or last name
00:13:34.079
or email and then pass in the three
00:13:36.160
parameters to this particular method and
00:13:37.760
the rails will use meta programming to
00:13:40.000
define this method first and then use
00:13:42.000
that method for actually u uh executing
00:13:45.360
the code that you are intending to use
00:13:46.800
and doing the search. uh just uh first
00:13:51.040
day of this uh uh conference when DHS
00:13:53.760
was speaking and uh this topic came up
00:13:55.680
about the dynamic finders and why it's
00:13:57.760
not there he mentioned that he tried to
00:13:59.199
use it for something and then it said
00:14:01.519
that this is not available and he
00:14:02.800
realized oh it has been removed and so
00:14:04.639
he blamed that someone who is working on
00:14:06.320
the performance might have removed it
00:14:08.079
which was Aaron so I talked with him as
00:14:09.920
well and he said even he doesn't know
00:14:11.519
who and why it got removed but there
00:14:13.440
should be good ways nowadays to handle
00:14:16.240
these kind of a methods with a
00:14:17.440
performance optim optimizations in mind.
00:14:19.120
So if you're looking for something to
00:14:20.480
contribute into the rail side, maybe
00:14:22.480
consider adding dynamic finders back
00:14:24.399
with performance optimized way uh about
00:14:26.880
it.
00:14:28.480
Yeah. So Ruby for developer happiness
00:14:31.199
and rails to make them smiley.
00:14:34.079
Moving on to the next part. Why the name
00:14:36.560
Ruby on Rails? So where does it came
00:14:38.399
from? So when the name Rails was thought
00:14:41.120
about, what DHSH intended it was that
00:14:44.560
Ruby as a web development. So you are
00:14:46.399
using Ruby for the web development but
00:14:48.160
it is not just that what you are being
00:14:50.480
given is a guardrails with a predefined
00:14:53.120
opinions and choices like a train
00:14:55.680
running smoothly on the rails and that's
00:14:58.240
why he intended to use the rails but
00:15:01.040
then a twist to that overall naming
00:15:03.120
schema is if you look at look on the
00:15:05.680
screen we have flicker tumblr or uh
00:15:08.959
delicious uh three of these websites now
00:15:11.600
there is something similar between these
00:15:13.519
three websites and ruby on rails
00:15:15.920
And uh you might think that these
00:15:17.680
websites or some part of their stack
00:15:19.600
might be built with Ruby on Rails. Um
00:15:21.600
absolutely not that's not the case. But
00:15:23.839
there is something similar and and that
00:15:26.160
similarity is all these things were
00:15:28.240
named because they couldn't get the good
00:15:29.600
domain name. Yeah. So Flickr, Tumblr and
00:15:32.880
Delicious just like them. Rails.com or
00:15:35.040
rails.org orgo was not available which
00:15:37.040
is why DHS had to think about okay what
00:15:38.880
can I name it differently for which I
00:15:40.880
have a domain available and then ruby on
00:15:43.040
rails.com was available and was
00:15:45.519
available so that's why it is named that
00:15:50.160
now we come to the one of the bigger
00:15:51.920
parts why convention over configuration
00:15:54.480
yeah so this is rails one of the most
00:15:56.720
famous and foundational principles
00:15:59.680
conventions over configurations and to
00:16:02.399
to go over it we will first understand
00:16:04.320
uh with an example like what is
00:16:06.000
convention over configuration. So in
00:16:08.000
case of uh let's say active record you
00:16:10.240
have a user class and the table in the
00:16:13.360
database for that becomes users. You
00:16:16.399
don't define that anywhere as a like if
00:16:18.880
you are building just the Rails
00:16:19.839
application you don't necessarily need
00:16:21.120
to define anywhere that my table is
00:16:23.759
going to be users and my class is going
00:16:25.279
to be user. You just create a class
00:16:27.040
called as user and the table is
00:16:28.880
automatically interpreted as something
00:16:30.720
like a users. If it's not there and if
00:16:32.399
you don't haven't configured it will
00:16:34.000
give an error but to begin with you have
00:16:35.759
a decision made for yourself. So you
00:16:37.600
don't need configurations right and the
00:16:40.240
reason it came to that was because of
00:16:42.800
the XML hell that was present back in
00:16:44.800
the day in 2003 and 2004 where the
00:16:47.600
developers uh were forced to explicitly
00:16:50.079
define every single mapping in verbose
00:16:52.639
and often in enormous XML files like
00:16:55.279
there was an example that uh got
00:16:57.600
discussed uh in one of such podcasts
00:16:59.279
that there were examples of XML
00:17:02.000
configuration files which were larger
00:17:04.160
and had more number of lines of code
00:17:06.400
than the working functional copy of the
00:17:08.079
basecam entirely. So imagine what kind
00:17:10.640
of a configuration files uh that were
00:17:12.480
there. So rails tried to flip this on
00:17:14.640
its head with the core idea that the
00:17:16.480
framework should make the intelligent
00:17:17.919
assumptions and provide the sensible
00:17:19.919
defaults freeing the developer from
00:17:22.480
specifying every mundane detail and this
00:17:25.600
convention or configuration is actually
00:17:27.520
a big antidote to the notorious XML hell
00:17:30.559
that was present back in the time. Now
00:17:32.799
directly uh so this this also directly
00:17:35.360
opposed the explicit is better than
00:17:37.520
implicit norm uh that was present in
00:17:40.080
this that era. Uh we still sometimes
00:17:43.360
prefer having things explicitly defined
00:17:46.160
and called out in our code instead of
00:17:48.240
having implicit things but when it comes
00:17:50.160
to the configuration having the them
00:17:52.160
more and more implicit helped out.
00:17:55.600
So the next thing that we talk about is
00:17:57.679
why uh dry where does it come from? uh
00:18:01.600
fortunately I wasn't very sure and I
00:18:03.600
couldn't find much of the things about
00:18:04.880
okay why this was included in the first
00:18:07.360
version of rails but then I had a quick
00:18:09.760
uh conversation with DH when he was here
00:18:12.559
and what he mentioned was it actually
00:18:14.400
came from the the book pragmatic
00:18:16.320
programmer which was a Dave Thomas book
00:18:19.360
and in that book what it says is every
00:18:21.840
piece of a knowledge must have a single
00:18:23.600
unamiguous and authoritative
00:18:25.360
representation and that's what the dry
00:18:27.520
is and that's that's why the dry got
00:18:30.400
included into the Ruby on Rails as a
00:18:32.000
framework. So even though it is an
00:18:34.080
important one caution that always should
00:18:36.080
be taken is to not do too much of a dry
00:18:38.720
because then it leads into uh premature
00:18:41.280
complexities within the application.
00:18:43.679
Moving on to the next part which is MVC.
00:18:45.760
So why MVC? So when it comes to MVC this
00:18:48.960
was something that was a
00:18:49.840
well-established pattern back in the
00:18:51.679
2003 2004 era and then the better part
00:18:54.799
of it was it perfectly aligned with the
00:18:56.720
rails uh convention or configuration
00:18:58.880
philosophy. So this particularly
00:19:00.640
eliminated need for repetitive decisions
00:19:02.880
and about how to organize the code. So
00:19:05.520
ended up not reinventing the wheel for
00:19:07.600
the MVC pattern and that got included.
00:19:10.320
Next, why active record OM? Uh this is
00:19:13.919
interesting because I explicitly added
00:19:15.919
the OM word there uh in front of the
00:19:17.760
active record because active active
00:19:19.919
record was uh until then was a name of
00:19:23.280
the pattern and this pattern was present
00:19:25.440
in Martin Fowler's book and in that book
00:19:28.000
he mentions that uh I mean the reason he
00:19:30.400
decided to have the active word in front
00:19:32.400
of uh this particular pattern or name it
00:19:35.360
as an active pattern was because active
00:19:37.840
was used to emphasize that the object is
00:19:39.919
not passive data container. Instead it
00:19:42.000
is actively participating in its life
00:19:44.400
lifestyle performing um database
00:19:47.200
operations directly and that's the
00:19:49.200
reason he called Martin Fer called it
00:19:51.039
active record and that pattern was taken
00:19:53.360
in and the OM was built on that and it
00:19:55.919
was called as an active record but the
00:19:58.240
other contribution that this particular
00:20:00.080
active record pattern did to the rails
00:20:02.320
is the naming conventions like active
00:20:05.200
versus action. So everything active
00:20:08.080
indicates that it's a fundamental or a
00:20:09.919
data or a utility related component
00:20:11.440
within the rails application. So
00:20:12.640
examples of that are active record,
00:20:14.559
active support, active storage, active
00:20:16.640
model and then the action is reserved or
00:20:19.600
indicates the components that handle the
00:20:21.360
user interactions or the web specific
00:20:23.440
processes. So on that side we have the
00:20:25.600
action controller, action view, action
00:20:27.360
mailer and action u view. Yeah.
00:20:31.760
Next is why um ACASI right the meaning
00:20:35.360
of that word is I will leave up to you
00:20:38.480
and there is a good blog post from 2012
00:20:41.039
uh that talks about this it was written
00:20:42.559
by DH rails is Omakasi and the
00:20:45.679
constraints that we have to understand
00:20:46.960
from that era that that uh DHH being the
00:20:49.919
only person who was working on the base
00:20:51.520
camp he had a few other commitments for
00:20:54.080
the uh 37 signals other clients also he
00:20:57.760
was a full-time student at the
00:20:59.200
university and combined with that he was
00:21:00.960
spending just 10 hours a week on the
00:21:02.320
base camp. So with the combination of
00:21:04.559
all these things uh he was pretty much
00:21:07.200
uh of the mentality that he's trying to
00:21:10.080
get a lot out of a little and um this
00:21:14.960
this resulted into rails being more of a
00:21:17.760
unique creation story where it was more
00:21:19.440
of a extracted and not built and um the
00:21:22.799
result was uh the web framework to
00:21:24.799
provide more scaffolding options and
00:21:26.559
support and that's why it ended up
00:21:27.919
becoming more of a batteryinccluded
00:21:29.919
approach and uh it is also noteworthy
00:21:33.120
that rails was one of the first to take
00:21:34.960
this approach of having the battery
00:21:36.559
included batteries included uh approach
00:21:39.440
of building the frameworks.
00:21:41.760
Next is uh why rest? Now rest was being
00:21:46.799
uh like it is something that got coined
00:21:48.720
in around 2000s itself but then there is
00:21:51.679
a good keynote talk from the uh DH in
00:21:54.480
2006 that talks about this particular
00:21:56.240
decision. So what happened was when the
00:21:57.679
rails 2.0 Z came in rest was prominently
00:22:00.880
included and
00:22:03.200
decided to be across the application
00:22:05.520
very prominently and some of the reasons
00:22:07.520
for such architecture were architecture
00:22:09.360
where uh simplicity and consistency.
00:22:11.679
Second was discoverability like
00:22:13.120
consistent URL patterns and controller
00:22:14.880
structures basically make it easier for
00:22:16.880
developers to understand and work with
00:22:18.240
the different rails applications. Then
00:22:20.080
better domain modeling. So this was one
00:22:21.919
of the important points. Uh so the CRUD
00:22:24.240
principles and overall CR CRUD uh is
00:22:27.280
something that took a lot of time in
00:22:28.880
that keynote where he explained why it
00:22:30.480
is important to focus on that and spend
00:22:32.799
time uh doing that because this leads to
00:22:34.960
the discovery of new and meaningful
00:22:36.960
resources like subscriptions membership
00:22:39.280
so it ends up uh aiding the good design
00:22:42.799
of the entire application and that's why
00:22:44.640
the CRUD was important and the API
00:22:46.640
development is also something that gets
00:22:48.080
easier u so all of that combined is why
00:22:50.880
the rest becomes so much prominent and
00:22:52.640
important within the rails.
00:22:55.280
Next we will so here we complete all of
00:22:58.240
our Y stories and now we go into more of
00:23:01.039
the other stories that we have. So one
00:23:03.039
of that prominent one is modularity and
00:23:05.360
the MER merger. So what MERB was was a
00:23:08.799
framework back in uh 2009 101 where it
00:23:12.320
was just more of a controller stack with
00:23:13.840
a rack and mongrel for web server
00:23:15.440
interfaces. Mainly the rack was
00:23:17.120
important. uh then it also had ERB for
00:23:19.520
views, data mapper for models but the
00:23:22.080
main important point about the MER was
00:23:24.000
that it was a multiple components coming
00:23:25.760
together and uh making MER as a
00:23:28.559
framework. So if you don't want to use
00:23:30.960
the MER in its entirety you can use the
00:23:33.039
components of it and that was possible
00:23:35.200
but rails until that point until Rails
00:23:37.600
2.0 wasn't something like that you use
00:23:39.840
entire rails or you don't use the rails.
00:23:41.840
So when the merger happened the rails 3
00:23:44.080
become more modular. It had a well
00:23:45.760
definfined public APIs so that the gem
00:23:48.159
developers and
00:23:50.240
uh others who are depending on those
00:23:51.760
public APIs don't have to uh face with
00:23:55.760
any of the APIs that are getting
00:23:57.039
deprecated. It also improved the
00:23:58.799
performance and the scalability and uh
00:24:00.720
it it provided a lot of upgrade lessons.
00:24:02.640
So for example you must have heard quite
00:24:04.559
a many times that the application
00:24:06.320
upgrades from 2.0 to 3.0 Z is something
00:24:08.640
that is very very hard and the reason
00:24:11.120
for that was this particular merger. So
00:24:13.279
from this point of uh from this point
00:24:15.919
onwards it become much more possible to
00:24:17.760
use multiple components within the rails
00:24:19.760
independently as well. So for example
00:24:21.520
the previous talk we saw where the
00:24:23.520
validators uh is something that you
00:24:25.360
could take out from the rails and use
00:24:26.720
independently. So things of things like
00:24:28.880
that are pretty much possible with all
00:24:30.720
of the things that are there uh in the
00:24:33.279
rails. Next is a story of a strong
00:24:36.000
parameters. So I would say this is one
00:24:38.080
of my f favorite stories. So we will
00:24:39.919
start what happened on 4th March 2012
00:24:42.559
wherein uh a developer from Russia
00:24:44.400
called this uh homacov uh created this
00:24:47.360
commit on uh rails repository on GitHub
00:24:51.360
uh and it was created from the DHS
00:24:54.240
account. So what happened there was he
00:24:57.919
was trying to convey some of the issues
00:25:00.000
or um security issues that that he was
00:25:03.279
finding in the rails applications but
00:25:05.279
then whatever that he was communicating
00:25:07.039
wasn't taken seriously and uh he had to
00:25:10.159
prove a point that these are valid
00:25:11.919
concerns. So what he did was on the
00:25:14.159
rails main repository in the main branch
00:25:16.400
he created a commit and he added some
00:25:19.840
comments from the DHS's account as well
00:25:21.840
on this particular PR saying that wa how
00:25:24.159
can I commit in master and then uh this
00:25:28.000
issue got very much talked upon a lot of
00:25:31.039
rails applications back then had to
00:25:32.559
immediately get updated uh to fix this
00:25:34.720
issue wherein the mass assignment was
00:25:36.320
the problem. So what was happening in
00:25:38.080
the mass assignment is here is an
00:25:39.600
example where you have a user new you
00:25:41.360
are taking certain parameters and you're
00:25:43.120
saving them. But then if you look at the
00:25:44.880
parameters hash it could be anything. If
00:25:46.720
this particular user has let's say a
00:25:49.279
role id or is admin true false then I
00:25:52.320
can pass in in the parameters is admin
00:25:55.120
true and then it will get updated and I
00:25:57.120
get admin access. Right? So that's the
00:25:59.679
problem and the way it got resolved was
00:26:02.000
using the strong parameters wherein when
00:26:03.919
you are calling user.create create and
00:26:05.360
passing the parameters to it. You need
00:26:07.120
to mention which parameters are
00:26:08.640
permitted for this particular action and
00:26:11.279
if there are any other parameters like
00:26:12.880
is admin then those will get rejected.
00:26:14.880
So that was the idea. So we will quickly
00:26:17.279
also look at the days before the
00:26:18.720
bundler. Um so quick note about like
00:26:21.679
what was there in the rails one which
00:26:23.039
was all plugins. Rails 2 had the first
00:26:25.200
class support for the plugins as a gems.
00:26:27.360
Rails 2 also added dependency on a rack
00:26:29.760
and then the tools that were being used
00:26:32.240
was something like a gem cutter. So here
00:26:34.559
is an quick example wherein we have
00:26:36.400
environment.rb and a config.je files. So
00:26:39.279
environment.rb specifying the rails gem
00:26:41.440
version which is 2.3.11. And if you look
00:26:43.600
at the config.je there are multiple gems
00:26:45.760
and the versions that are mentioned in
00:26:47.840
front of you. Uh so you will also see
00:26:49.600
that some of the gems are coming from
00:26:51.679
the gems.github.com.
00:26:53.600
So uh it used to be uh specification of
00:26:57.039
the gems like this without having any
00:26:58.880
gem file or gem file. And then you need
00:27:01.120
to install that with the rake gems
00:27:02.640
installed. And if you have a two three
00:27:04.559
applications on the same machine with
00:27:06.000
different Ruby versions or even the
00:27:07.520
different gem versions, it used to be a
00:27:09.760
hell to fix that and get multiple
00:27:11.840
applications running on your machine. So
00:27:14.000
all of that get solved when the bundle
00:27:16.080
bundler came into the picture which
00:27:17.600
provided the per per application
00:27:19.200
dependency resolution. It provided with
00:27:21.520
a gem file and gem file.lo to manage the
00:27:23.679
dependencies correctly. Um just a quick
00:27:26.240
note from back in those days when uh
00:27:29.120
there was a one suggestion that I had
00:27:30.640
provided for u adding the version
00:27:33.440
numbers into the bundler which got
00:27:34.799
implemented. So for example what we have
00:27:36.480
here is fetching SAS 3.7
00:27:39.760
was 3.5.7. So this particular
00:27:42.400
notification got added uh to indicate
00:27:44.960
whether it was a major version upgrade
00:27:47.200
or a minor version upgrade.
00:27:49.919
And then coming to the other stories
00:27:51.520
from the last rails conf uh I would say
00:27:55.279
last meaning this rails conf there are a
00:27:57.440
couple of other talks that also talking
00:27:59.200
about other areas of rails and from the
00:28:03.039
point of view of historical features and
00:28:04.880
evolution of them. So I decided not to
00:28:06.880
include them. So there are certain talks
00:28:08.880
that are focusing on the front end then
00:28:10.559
certain that are focusing on the
00:28:11.919
deployment side certain that are about
00:28:13.679
the background jobs u and then real
00:28:16.480
features uh which ones we loved which
00:28:18.559
ones we lost and laughed at. So overall
00:28:21.600
what's the conclusion? I would say
00:28:23.120
overall uh this is how the overall
00:28:26.000
picture from 2005 to 15 and from 15 to
00:28:29.360
25 looks like where if you see in 2005
00:28:32.960
uh there were just about six core
00:28:35.200
elements that were present. Uh in the
00:28:37.120
second picture if you see uh at least
00:28:39.360
four new got added into it and then in
00:28:41.760
the last 10 years uh even more got added
00:28:44.720
uh into rails. And lastly, we'll quickly
00:28:48.080
just look at some of the nostalgia from
00:28:49.840
the past. Um, so this used to be the
00:28:52.320
first uh website for the Ruby on Rails.
00:28:55.200
Agile web development with Rails was
00:28:57.919
kind of the only book back then 2009
00:29:00.080
when I started. Uh, this used to be how
00:29:03.679
API documentation used to look like. Uh,
00:29:06.159
it used it it worked. Uh, but yeah, just
00:29:08.880
that nothing else. Uh, Rails cast this
00:29:12.320
was very very popular back then. Uh a
00:29:14.640
lot of people will have a very fond
00:29:16.159
memories of listening to Ryan Bits uh on
00:29:18.880
the Rails cast. Yeah, that's that's all
00:29:21.760
I have. Thank you.