List

Your First Rails Pull Request

Your First Rails Pull Request

by Mark McSpadden

The video titled 'Your First Rails Pull Request' features Mark McSpadden at Rails Conf 2013, where he provides guidance for developers interested in contributing to the Ruby on Rails framework. McSpadden emphasizes the importance of giving back to the Rails community and walks through both technical and non-technical aspects of making your first pull request.

Key points discussed include:
- Inspiration to Contribute: Contributors often aim to improve Rails, enhance their own understanding, or gain recognition within the community.
- Ecosystem Overview: Understanding the organization around Rails pull requests, including the roles of the core team and issues team, enhances communication and expectations.
- Motivations for Contribution: Contributors may want to make the world a better place, ease their own workflows, or achieve fame within the community.
- Selecting Issues: Developers can start contributing by addressing personal pain points, exploring the Rails issues list, or working on supporting gems, taking note that many issues require considerable effort.
- Getting Involved: McSpadden encourages participation in discussions via the Rails Core mailing list and direct communication on GitHub.
- Setting Up a Development Environment: He highlights the importance of using tools like Rails Dev Box to streamline the contribution setup.
- Pull Request Process: Key steps include researching the issue, coding, reviewing, testing changes, and submitting the pull request while adhering to guidelines like documenting changes and cleaning up commit history.

Examples & Anecdotes:
- McSpadden shares his personal journey in contributing to Rails, noting that during one year, he aimed to submit a pull request every month, which resulted in nine accepted contributions.
- He humorously mentions the diverse motives for contributing and the realities of the pull request process, such as the initial complexity followed by valuable learning experiences.

Conclusion & Takeaways:
The video encourages developers to take the leap into contributing to Rails, highlighting that the learning and improvement gained through the process far outweighs the challenges. McSpadden's insights and structured guidance provide a clear pathway for first-time contributors to engage with the community and become part of the open-source ecosystem.

In summary, Mark McSpadden inspires and equips developers to contribute to Rails with both confidence and clarity, underscoring that every contribution, regardless of its scale, enriches the entire community.

You have been doing this Rails thing for a while and you're starting to feel like it's time to give back. Great! Now what?
In this session we'll walk through the technical aspects of getting started with contributing back to Rails as well as the non-technical tips, tricks, and considerations to keep in mind along the way.

Help us caption & translate this video!

http://amara.org/v/FGaM/

Rails Conf 2013

00:00:16.480 okay welcome we're gonna get started welcome to your first rails pull request
00:00:22.400 other working titles for this talk have been how to submit a pull request to rails without everyone laughing at you
00:00:28.640 and how to submit a pull request to rails without being a complete jerk uh the second one is actually a lot harder than the first one
00:00:35.840 i am mark mcspadden you can find me on the githubs on the twitters just about any place i try to grab the mark
00:00:42.079 mcspadden name i work at sabre who has heard of saber
00:00:47.520 like eight people so we serve back ins of travel systems airline
00:00:52.640 reservations hotel reservations we own this company called travelocity you might be familiar with
00:00:57.920 we do about a billion api calls a day none of it in ruby and they don't let me
00:01:04.000 touch any of it i run the tech side of sabre labs the group of volatiles that
00:01:10.479 fights with the stables if you were here for that talk we're based in dallas i helped organize
00:01:15.520 the dallas ruby brigade and this year we were at our first conference called big ruby who had who's
00:01:21.200 heard of big ruby like another five people conference in dallas we're going to do it again next
00:01:27.439 year it's about people doing big things with ruby really good feedback from the content in fact you're in here which means you're
00:01:33.920 not next door at brian's talk brian gave a talk on services and rails
00:01:38.960 and the stuff they don't tell you at our conference it's up on con freaks so you get a two for one by being here
00:01:45.759 today kind of cool all the videos are up on con freaks i really encourage you to check it out so are you impressed yet have i established
00:01:52.000 my authority as a speaker that should be up here please do not be impressed
00:01:58.880 i feel like i believe i belong out there someone else should be up here
00:02:05.119 this is my github open source graph who has a graph that looks better than that
00:02:10.160 in here yeah it's lots of people good job way to go
00:02:16.640 so how did i end up here so to ask that we'll fast go way back to
00:02:22.319 2012 beginning of the year i've been doing rails for six almost
00:02:28.480 seven years at the time and i'm like you know what it is time for me to start giving back you know you just have that
00:02:34.000 inside you feel like okay it's it's about time and so because at the beginning of the year it's the time of year we make bold proclamations
00:02:41.200 so i said i'm going to submit a pull request to rails every month for the whole year
00:02:48.000 now a couple of things about bulk proclamations number one i don't make them in public anymore
00:02:54.319 so i just told myself this um also i didn't set the bar really high notice i said submit a pull request i
00:03:01.200 don't even care if it gets accepted at this point just hitting the submit button is a big deal i'm sure you can
00:03:06.720 help you guys can all see where this is going obviously i failed
00:03:11.840 but i did end up with some pull requests so 10 total per request to rails nine of them were accepted and this talk
00:03:18.959 is a little bit about what i learned along the way
00:03:24.080 but big red disclaimer is that i'm not on the rails core team i'm not on the rails issues team i'm not on any other
00:03:31.760 secret rails team that i don't even know exists um and i do not speak for them but i
00:03:37.440 feel like i'm a lot like you and that means i feel like i can help you with your first real pull request and
00:03:42.480 speaking of you how many of you have attempted to submit a pull request to rails
00:03:48.879 wow there are like seven hands eight hands okay how many of you got accepted
00:03:54.159 oh good rate okay okay how many of you have submitted a pull request to anything on github
00:04:01.680 oh okay that's a lot of hands okay okay so we're gonna talk a little bit about
00:04:08.000 why we contribute to rails hopefully you can get inspired that this is something that you can actually do i believe that
00:04:13.280 you can do this if i can do it you can do it trust me so why would you contribute to rails one
00:04:18.400 is to make the world a better place oh that's great
00:04:24.639 actually i joke about this but it's kind of where i was last year if you were who was that ernie's talk yesterday a lot of
00:04:30.240 people so that talk kind of ramps up at the end like make active record better and you kind of come away and you're
00:04:35.600 like i'm going to do that i mean i didn't do that i had to work on these slides but hopefully you went away and
00:04:41.520 you were like i'm going to work on active record which is a great motivation to make the world a better place
00:04:47.680 another motivation is to make your life easier maybe you think that by changing the way that rails works
00:04:53.759 your job will be easier i have to tell you this is a really long play if this is your motivation
00:05:00.560 this is a very scientific graph of your quality of life over time you see the
00:05:06.160 point at which you say i know i'll submit a pull request your quality of life goes significantly down for a while
00:05:12.720 and it does come back up after the pull request process is complete and then you do have a better life but that can take
00:05:17.840 it's a variable time it's kind of crazy so the third reason which i think is
00:05:23.840 actually the most important reason to submit a pull request to rails is to better understand rails
00:05:29.280 this is the gold star double unicorn rainbow reason uh i've learned so much
00:05:35.199 about not only the ecosystem the tools around rails its internals just by being willing to spend
00:05:41.759 a few hours on a given day digging into an issue or trying to make something that i thought was important come to
00:05:48.000 life i think this is the reason you should be trying to contribute to rails and it
00:05:53.840 works out pretty well because it's self-serving so also fourth reason is to get famous
00:06:00.479 that's why you should contribute to rails i'm kind of serious who's seen this site
00:06:07.120 oh this site is awesome you learn about it when you uh get your first pull request submitted because you are on the
00:06:13.919 leaderboard of contributors to rails contributors.rubyonrails.org you can see
00:06:20.720 here i'm number 336 i'm also the sixth mark on the list i
00:06:27.199 was like fourth and then some other marks got ambitious
00:06:33.039 this becomes a game in and of itself uh which i think is a really interesting element i think it's a really fun thing
00:06:38.720 to do there's also filters on it where you can sort by month or like one month i was really active and i was like i'm
00:06:44.319 the third best this month um this can be this can be a motivator for you
00:06:50.400 so hopefully one of those things kind of fits where you're at you want to make rails better you want
00:06:55.840 to make your life better you want to better understand rails or you want to be famous um and so i want to give you a quick
00:07:02.000 overview of the what i'll call the ecosystem around pull requests we don't talk about this much
00:07:07.039 but it's really kind of hard to grasp unless you're in there and i want to set your expectations for what you can
00:07:12.160 expect uh in that ecosystem i mentioned earlier i work at a really big company we have a
00:07:17.680 joke that no slide deck is complete without an org chart so i went to look for a rails org chart and there's not
00:07:24.160 one so i think i present to you the first ever rails org chart which i don't
00:07:30.800 think is all that great but some things i want to point out there is a core team you guys familiar with them they make
00:07:36.000 decisions about where rails is going they commit a lot of code they have commit bits there's also an issues team
00:07:42.639 how many of you familiar with the issues team a few of you okay so the issues team has been around for
00:07:48.080 only about a year and their main job is to triage issues as they come in railsconf last year we had a ton of
00:07:53.919 issues in rails they have been amazing and taking that list
00:07:58.960 asking for more feedback closing issues that aren't relevant this group is probably the one you're
00:08:04.960 going to interface with most if you're having conversations about your pull request
00:08:10.400 and then over here on the far left there are more than just rails rails in the rails organization on github and so
00:08:17.360 there are people that maintain these gems like turbo links and j builder and remember axes list like that's a that's
00:08:24.400 a different repo now and they all have maintainers and then there's us and we the reason that
00:08:30.240 i think big organizations have problems with open source sometimes they don't get this org structure that like everybody talks to everybody but it's a
00:08:37.120 really really unique ecosystem we have that at any point we can be talking to any one of these people
00:08:42.959 and i just thought it was cool to call it out oh how is that still in there it's
00:08:48.800 actually my draft of the org um chart what you should know about the
00:08:55.040 ecosystem is how to communicate so there are a couple of ways uh people that contribute to rails communicate the
00:09:01.279 first one is through the rails core mailing list who has subscribed to this list
00:09:06.399 okay this is like the first actionable thing you can do is subscribe to the rails core mailing list it's a google
00:09:13.279 group the volume is super low five emails a week sometimes sometimes
00:09:18.800 up to ten go ahead and subscribe to get every email this is where discussions happen about what goes into rails now
00:09:25.200 not every discussion of everything that goes into rails happens on this mailing list but you can subscribe you can
00:09:30.640 listen to conversations this group's open you can post questions you can ask questions like hey i have this pull
00:09:36.480 request it's been out for a really long time can somebody please look at it great great resource
00:09:44.640 secondly com communication happens within github itself so there are two main ways well that's hard to see at the
00:09:51.120 very top of when you're in the rails rails repo there's a watch button that is like the fire hose of rails
00:09:58.640 if you do that that is awesome i can't handle that um also what's interesting is on the bottom of each issue
00:10:05.200 there's a watch button for that issue where you get updates you'll get emails
00:10:10.240 whenever a new comment is added or something changes on that issue i think that's a really cool feature if you're interested
00:10:16.880 in something that's going on or maybe you have a bug that someone's already reported watch that issue see what's
00:10:22.320 going on with it it's a good way also face-to-face communication conferences meetups this is the help
00:10:28.560 desk from yesterday these conferences are a great opportunity to sit down and talk with
00:10:35.279 people that are actually putting things into rails asking them questions sharing your ideas sharing your thoughts
00:10:41.680 sharing your pain with them take advantage of these opportunities and more than likely if you go to some
00:10:48.320 kind of meetup there is somebody that is either on the the core team or issues team or they know somebody that is it's
00:10:54.800 a very i mean there's a lot of us here it's a very small world so some quick stats on pull requests and
00:11:02.480 these are going to be since the uh end of rails conf last year is that there were 2 912 pull requests
00:11:10.640 opened over the course of the year about 8 a day of those
00:11:15.720 1916 were actually merged in so we've got about 3 000 almost 2 000
00:11:21.680 merged in your chances of being merged into rails are really good if you submit
00:11:28.000 a pull request think like the guy in the price session said yesterday that's like over half
00:11:35.839 now of course there were some that are rejected and rejected isn't really a
00:11:40.959 status what happens is your your pull request gets closed and it's not merged
00:11:46.320 in it's kind of that it's not you it's me thing they don't say like rejected they just close it and don't merge it
00:11:53.360 about 27 of the pull requests were rejected last year and 200 pull requests
00:11:58.399 over the course of the year still open these are like zombie pull requests i don't know if these ever get solved
00:12:05.360 so let's talk a little bit about the merged pull requests so the average time for one of the
00:12:10.639 merged pull requests to go from being open to being accepted in the rails 5.5 days
00:12:15.760 you should all be like averages lie 74 percent of them less than 24 hours
00:12:23.600 that's amazing for an open source project the people that work on this deserve a whole lot of credit
00:12:30.560 and if you want to go out to the 90th percentile we're talking nine days ninety percent of the merged pull
00:12:36.240 requests were merged in within nine days let's flip over and talk about the ones that were rejected
00:12:42.000 the average time to rejection is 18 days averages still lie
00:12:48.320 about half are we are closed and not merged within 24 hours and then
00:12:54.399 within a week we're talking 73 of them so what i want you to take away from this is that the pull request process
00:13:00.399 seems like it takes a long time sometimes and especially when you're in it it feels that way but really within
00:13:05.519 the first day you're going to know a lot about your pull requests and within the first week you're going to know even more so i want this to be a piece of
00:13:12.399 encouragement that this is not a lifelong commitment once you sign up to say i want to do a pull request this is something you can
00:13:18.560 do in a week or even a weekend
00:13:23.680 and then one more little semantic thing classification of a pull request and an
00:13:29.600 issue a pull request is an issue an issue is not a pull request
00:13:36.560 you hit the issues page you'll see the issues that have pull requests code with them and those that don't see that
00:13:42.800 you've got little logos if you hit the pull request tab you see just the pull requests if you want to see just the issues with
00:13:49.360 no pull requests in them you have to use your eyeballs there's no button for it that i found
00:13:55.600 surely in a room this size there's at least 50 people that work for github maybe we should talk about this
00:14:04.079 okay so we spent some time we've run through uh being inspired why do you want to contribute to rails we've talked
00:14:11.120 a little bit about the ecosystem so that you know what you're getting yourself into hopefully so now how do we actually go about
00:14:18.000 submitting a pull request so first you have to pick a thing to work on this is actually kind of hard
00:14:26.240 and there's lots of places that you can find this thing you can find this thing from your personal experience
00:14:31.360 it can be your own vision for a feature it can be from pain and anger
00:14:37.120 uh one thing i will mention is that anger leads to hate and hate leads to suffering so uh that's what yoda said so
00:14:44.240 be careful about spending too much time here but this is a good springboard
00:14:49.519 and another thing especially about these types of pull requests
00:14:54.720 i recommend to build first and discuss later there's a lot of messages on the core mailing list that go something to
00:15:01.680 the effect of this hey i think it'd be great if this thing
00:15:06.959 was able to do this thing like this if anyone is interested i'll work up a pull request
00:15:13.120 okay i get i get we don't want to waste our time but part of doing a pull request is
00:15:19.120 understanding rails better so i always think it's better do the pull request learn as much as you can about rails and
00:15:26.240 then let's talk about whether it's worth it or not later
00:15:31.360 okay so we talked about personal experience you can also go pull things off the rails issues list
00:15:36.480 there are a lot of rails issues this was last night yesterday ernie pointed out yesterday a lot of
00:15:42.880 them are an active record but there are a lot of myths about issues that i kind of wanted to talk
00:15:49.120 about the first myth is that there are a lot of these little issues that are just waiting for me to like swoop in on like
00:15:55.199 a 15-minute break and like solve real quick that's not true
00:16:01.040 i think steve klovnick tweeted a couple of weeks ago that if there were any issues like that he would have solved
00:16:06.240 them because i think he knows where he is on the contributor board and where he wants to be as well
00:16:12.079 so this if you're going to pull something off the issues list it's a multi-hour
00:16:17.360 thing like it really is i don't do that to scare you i do that to tell you take the
00:16:23.360 time to do it like block off a saturday morning block off one of your hack nights like
00:16:29.839 you can do this just don't be surprised that it takes an hour to get into the problem
00:16:37.759 myth number two is that if i comment on an issue people will mistake me for
00:16:42.959 someone that's really important like a core member or something like that i had this fear like when i was so if i
00:16:49.440 go through the issues list i might say can you tell me more about the problem can you clarify what version of rails
00:16:54.720 you're using what version of ruby and i was scared that they were going to think that i was somebody like important but then i realized that
00:17:00.959 both my picture and my name are a link to my github page and they find out really quick that i'm not that important
00:17:06.959 so this should not be a reason for you not to ask questions on somebody's issues feel free to ask the questions of
00:17:13.360 are you still having this problem what version of rails are you using what version of ruby are you using can you
00:17:18.880 create a gist for this like all kinds of just clarifications if you're really going to dig in on an issue you want to
00:17:24.799 know as much as possible about it and myth number three is that people that comment on issues are jerks and
00:17:31.760 they'll get pulled into these big things that end up on hacker news the comment threads are really pretty
00:17:37.120 boring um you can't you can't find a lot of yeah every once in a while one of them blows up and we all know what
00:17:43.360 happens there but for the most part these things are boring you can be nice and do this
00:17:50.000 so the other spot we can pick up things is the supporting gyms uh how how many of you know how many gyms are
00:17:57.280 repos are actually in the rails org a few right there's a few repos under the
00:18:02.799 rails or there's 66 repos under the rails org right now that's a lot of code
00:18:08.640 that's more than just rail slash rails of those 20 of them have been updated
00:18:14.080 within the last month i'd call those fairly active projects and of those 20
00:18:19.600 uh 14 of them have open issues today now the great part about using one of
00:18:24.960 these support gyms is that usually the code bases are smaller usually the politics are smaller
00:18:31.600 and the opinions are smaller and people just the people that commit
00:18:36.640 to these really really want your help that some of the feedback i got when i when i sent some uh some surveys out so
00:18:44.400 really view these as an opportunity uh to contribute to rails now if you're
00:18:49.520 looking to if your inspiration was to get famous i have to tell you you don't end up on the contributors contributors.rubio ruby
00:18:56.400 on rails.org list if you commit to one of these other gyms so if that's your motivation this might
00:19:02.160 not be the one for you but if you want to make the world a better place totally the place to start
00:19:09.600 and then there are security pull requests uh who is in the security is hard talk
00:19:14.640 okay a couple people do not submit security issues via pull requests
00:19:20.320 everybody got that if you found a security issue do not submit it via a pull request there is a whole page about what to do
00:19:27.440 with it rubyonrails.org security this outlines the process for submitting those so do not submit a pull
00:19:34.320 request for that good okay so we picked the thing the next piece which i think gets
00:19:40.320 skipped a lot is to research the thing and this is really just searching search github issues
00:19:46.640 search the mailing list search stack overflow get really familiar with
00:19:52.400 the thing that you're working on my first pull request into rails was an inflection bug
00:19:59.120 now if you do a single search on inflection and rails core you'll find out really quickly the core does not not
00:20:07.120 accept patches on inflection anymore it's frozen it's too fragile it breaks
00:20:12.799 too many things when we change it okay that's the stance and i was like i don't care i'm going to do it anyways
00:20:19.360 but part of knowing that i was really careful i knew the domain and during my pull requests i can talk about how i
00:20:26.160 presented an argument of why i thought it should change and it did change so being knowledgeable about what you're
00:20:31.760 working on very very important so we are
00:20:37.679 20 minutes into the talk and now we're going to talk about computers which is great so setting up your
00:20:43.280 environment to contribute to rails there is a site on the guides for contributing to ruby
00:20:49.919 on rails i want to point something out really important do you want to use the edge guide on this topic you get to the edge guide
00:20:57.039 two ways one way is if you are on the readme of rails rails the link to contributing to rails goes to the edge
00:21:04.080 guide otherwise go to guides.rubyonrails.org and then put the word edge on the front half of the
00:21:10.960 subdomain the reason that you want the edge guide is because it has this section setting
00:21:16.240 up a development environment and it has this subsection which is the easy way and the hard way if you use the
00:21:23.360 regular guide there is no easy way there's only the hard way and you don't want to do that because i did it and i
00:21:29.440 liked the easy way so what is the easy way the easy way is a project oh look it's a
00:21:36.320 it's a project under rails again it's called rails dev box anybody used rails dev box
00:21:42.640 one person two people we can change that by the end of the day i'm sure um
00:21:48.880 creates a virtual machine for you to do core development and what that means is that there are a
00:21:54.000 lot of dependencies that rails needs to run all its tests like you need my sql postgres sqlite all configured in a
00:22:00.080 certain way you need lots of packages lots of different things stuff that you don't have to worry about when you're
00:22:05.200 developing on rails but when you're testing rails you have to worry about this virtual machine comes with those
00:22:10.799 all pre-baked it has a couple requirements virtual box
00:22:15.919 that's free vagrant that's free and so what do you do
00:22:22.159 first you open your purple terminal the purple is important we'll get back to it
00:22:27.760 you clone the project you see the in the directory and you say vagrant up and this is actually going to take a
00:22:34.320 really a while because the virtual machine doesn't actually come with the project there's a
00:22:39.600 link to the virtual machine so it has to download it and then do a bunch of stuff but while you're waiting on it we can do
00:22:45.200 other things like fork rails people fork github repos before
00:22:51.440 some forking some not okay we'll go through it really quickly there's a fork button on rails rails
00:22:57.440 it brings up your profile if you have multiple organizations ask you where you want it that's travel chewy he's our
00:23:02.559 mascot then you get this that used to say a hardcore forking action but doesn't
00:23:07.919 anymore and then you end up on your fork of the project
00:23:14.080 okay so then we drop into a blue terminal different than the purple terminal
00:23:19.679 different but we're going to go to the same place and location here matters a little bit i know that when i'm running
00:23:26.000 through like tutorials and it's like and go to this directory and then clone this project you're like i'll clone it where
00:23:31.039 i want to thank you very much trust me just a little bit on this one
00:23:36.559 is that you want to go to the same spot where you pulled out the dev box clone from rails rails
00:23:42.880 there are two different workflows like starting with cloning from rails rails or starting to clone from your
00:23:50.159 fork of it i find the rails rails flow just a little bit easier when it goes to
00:23:56.960 pulling down stuff updating your copy and i think it's a little bit better you can do it the other way if you prefer
00:24:03.679 so you'll clone rails and then you'll have a rails directory you're going to cd into it
00:24:08.960 and then you're going to create a branch for whatever you're doing naming here is kind of arbitrary i stick
00:24:15.760 with like a feature underscore if i'm adding something a fixed underscore issue number if i'm trying to fix
00:24:21.520 something and then you open up your text editor see i told you not to be impressed i don't even use one of those elite editor
00:24:28.000 things but so we've done that now we can go back over to our purple terminal
00:24:33.279 and up here we can see that vagrant has spun up and what we're going to do is we're going to ssh into the
00:24:40.080 virtual machine kind of cool we don't even have to know credentials or anything just do vagrant ssh into this virtual machine
00:24:46.960 and then if you uh list slash vagrant directory this is why it matters where you put rails
00:24:53.279 this rails is the mirror of the rails you cloned in the blue terminal so
00:24:58.640 we're gonna we're gonna have a workflow here that's pretty cool so we do a bundle install on here and then we run
00:25:04.240 rake and look you can run the rails test that is a big achievement don't ever run all
00:25:10.880 the rails tests i was really surprised when i read this
00:25:15.919 in the contributing guy they're like yeah we have ci and it takes the ci like 16 minutes it will
00:25:22.480 take i i've been trying to run them off and on like while i've been here and i just haven't got through the whole test suite in a single setting any time
00:25:30.320 so the the recommendation is to definitely add your test test what's around it and test the main gem around
00:25:38.000 it so if you're doing something on active support run all the tests for active support if you're doing something on active record
00:25:43.440 do that the only caveat is if you're doing something in rail rail ties they ask you to test the whole suite but for
00:25:49.679 the most part you shouldn't have to run the whole thing ever that's really scary because i've had the ci go red on something i did before and
00:25:55.919 that makes you feel really bad but that's what they told they tell us to do so just let's just do it and here we go
00:26:01.600 this is running if you cd into one of the gems active support and run rake it'll only run
00:26:08.159 the test for that gem also this one's a little harder to read but you can just run a single test file
00:26:15.120 or you can run a single test file and a single test within it this is one of the things that i feel like is really
00:26:20.640 important about contributing back to rails is you get better at some of this stuff that you may not do in your test suite all the time like you may just run
00:26:27.279 rake every time or rate test or rate spec or whatever this exposes you different ways of having to work around those issues
00:26:37.360 25 minutes and now we now we can code our thing
00:26:43.120 all right okay and so we've got a workflow here we're going to work we're going to code on our physical machine
00:26:50.320 and we're going to test on the virtual machine okay code on the physical machine test on the virtual machine
00:26:57.679 and this is where you go code spelunking the
00:27:03.840 some pieces of rails are really easy to get in and out of like they make a lot of sense some of them aren't
00:27:11.840 there's a big push for needing help on active record and it's a really gnarly code base there are a lot of fixtures if
00:27:18.080 you ever want to feel better about the choices you've made in your test suite
00:27:23.120 go look at active record and you will feel instantly better about your code base but we can't just ignore it it's not
00:27:29.919 going away i think it's important to lean into and so this is where
00:27:35.440 you have to figure out how to best contribute to rails so you coded good job wow that was quick
00:27:43.360 so now it's time to review and reflect a little bit
00:27:48.960 so ask yourself a few questions does this match the style of the code around it
00:27:54.559 i think this is really important there are style guides on indentation and using andan instead of
00:28:01.200 the word and that the style guides are in the contributing website but really look at everything around it
00:28:07.760 does your code fit could this hurt performance and have i
00:28:13.360 benchmarked it uh one of the pull requests i did which i'm super i'm super excited about rails 4 because most of
00:28:18.559 what i've done is isn't coming out until rails 4.
00:28:24.799 a core extension and active support to hash which is transform keys this is we used to get in a discussion about once a
00:28:31.360 month about what's the best way to transform a key on a hash to use inject to use each with object so what i did is
00:28:37.520 i refactored stringify and symbolized keys to be transform keys and
00:28:45.039 everyone was like that's great we use those all the time in rails how does this affect performance and i was like
00:28:52.159 um so lots of benchmarking i learned a lot about benchmarking and how the rails
00:28:58.240 team expect benchmarks to be done i was using really big hashes to benchmark against they were like no we
00:29:03.279 use a lot of small hatches a lot of times so some really interesting just learnings which is
00:29:09.600 i think still the best reason to do this what are the future maintenance
00:29:15.120 implications of my change this is really interesting to the core team because they have to maintain it
00:29:20.480 and you may just come and throw it over the wall and leave so make sure you've considered this and then of course does
00:29:26.159 this make rails a better place you hear a lot about the code test does the code i write because of this improve because
00:29:33.360 of the addition you've made to rails obviously if it's a bug fix that answer is yes
00:29:38.960 if it's a feature then there's a lot more debate about it and then find a friend
00:29:45.760 have someone look over this with you these are my girls find someone that can look at the code
00:29:51.760 with you talk about it with them because you're going to want a friend before you go in and submit your pull request okay
00:29:59.039 so find a friend then one more time run the test just the ones you need
00:30:04.640 update the change log so if you are adding a feature or fixing a bug they ask you to update the change
00:30:11.039 log with that if you are just doing a refactoring they ask you not to update the change log
00:30:17.360 just to be aware of that and then squash your commits usually this isn't a big deal the first time you
00:30:22.960 try to get everything in like one commit but kind of the rule is they want one one commit per pull request
00:30:29.919 squashing commits is a little bit outside of what we'll do here but there's lots of guides online with
00:30:35.520 it it's really scary the first time you do it and then the second time it's really kind of oh okay i mean this
00:30:41.039 happens more if you go back and forth and need to make changes on the code that you've submitted during your pull request
00:30:47.200 okay we have about 10 minutes left so we'll talk about submitting a pull request
00:30:52.640 okay so here we go we're going to commit remember we're working on our branch
00:30:58.000 and then we wouldn't have to do so much stuff except for rails is an ever changing
00:31:03.760 base so what we have to do is before we submit before we push our branch
00:31:09.919 to our forked repo what we're going to do is we're going to rebase from rails rails because there was a lot of stuff
00:31:16.080 going on in rails since the time you checked it out so we're going to make sure we have all those changes make sure we didn't break anything so the way to
00:31:21.840 do that is here we check out master you do a git pull rebase and this this is where i said it matters that you pull
00:31:27.919 you clone from rails rails instead of your rails we're going to check out our branch and
00:31:33.200 then rebase it to master then we're going to get remote add you only have to do this the first time
00:31:38.880 we're going to add a remote called mine which points to hey your rails and then you're going to push your
00:31:44.640 branch up there okay that's all you have to do on your machine that's it then you go then so you're not done then
00:31:52.159 you go to github and you go to your rails up here and you say okay i want to
00:31:58.880 submit a pull request so now you're in pull request mode
00:32:05.039 okay and you can totally hit that button and nothing bad will happen so if you just want to like go home today and like hit
00:32:10.480 the pull request button like do that just to see what this looks like on your machine you're going to pick the branch
00:32:15.600 that you just pushed up you say oh yeah i totally want to uh pull request from this branch to rails master
00:32:22.960 this is where you're going to write a summary we'll talk about that in just a second of the other tabs or commits there should be one of these
00:32:30.000 and then the file changes like this is the diff of what you did which is really cool to look at your diff
00:32:36.320 so summary explain your explain yourself show how smart you are show how much
00:32:42.799 research you've done on the topic link to any performance benchmarks or any other issues
00:32:49.360 and then i think this is some secret sauce cc people so the issues team does a really good
00:32:55.200 job of trying to kind of spread the pull requests out where they think they belong one of the things i like to do
00:33:00.960 especially if i've had a pull request that's sitting stagnant for a couple of days is do a get blame around the code
00:33:07.440 that you just changed see who's been working on it cc that person they'll get an email if
00:33:13.919 you say at person they'll get an email it helps move things along
00:33:19.919 so use git to your advantage here and then you submit the pull request
00:33:25.120 and then you wait and you i'm telling you walk away from your computer
00:33:31.039 like walk away uh i trust github a lot i don't know if they can handle the amount
00:33:36.480 of refreshing that will happen if you just stay at your computer and then someone will comment on it or
00:33:43.039 say something or merge it and then you respond and you go back and forth and then oh my goodness you go there one
00:33:50.320 day and look it says merged this is so cool like i can't even
00:33:56.399 describe you the feeling that this is like think about solving that really really hard problem with code like this
00:34:01.679 is better than that because someone else validated it um and then sometimes it doesn't work out
00:34:08.079 so well so they close the issue and then you get this but you still learned a whole lot like i
00:34:15.280 can't stress this enough you are a better rails developer because you went through this process
00:34:23.599 wrap up real quickly i think you should be inspired to contribute to rails i think there's lots of reasons why it's good
00:34:29.440 we have a great ecosystem for accepting pull requests and having you be able to
00:34:34.720 contribute i sent a note out to the people on the rails the members listed on the github org
00:34:42.079 and i just asked them a few questions when i knew i was going to give this talk i said so what are the biggest mistakes you see people make they said
00:34:48.000 no texts and no docs tests and docs it's pretty simple let's
00:34:53.359 do this then i asked them so what's your favorite pull request of all the ones you've seen and most of
00:35:00.560 the responses i got back were well my favorite one is my first one
00:35:05.839 so your favorite pull request is waiting for you go make it happen thanks
00:35:49.200 you