#117 Upgrading Ruby on Rails Versions


In this episode, we look at updating a Ruby on Rails application from v4.2.10 to v5.0.6. The overall steps taken will vary from every application, but the concepts applied will relatively be the same.
rails upgrade 23:23

Early Bird Pro Subscription Pricing!

From now until Mar 01, 2018, save on the Pro Membership!
Get the Pro Membership for $9.00 USD per month while you maintain an active subscription.

  • Student & Teacher
  • $9.00 / month
  • Valid School Email Required
  • Same Access as Pro
  • Subscribe Now
  • Pro Membership

    Early Bird until Mar 01, 2018

  • $9.00 $15.00 / month
  • Access to Pro Episodes
  • Invite to Slack Channel
  • Priority Episode Suggestions
  • Ad Free
  • Subscribe Now
  • Teams
  • starts at $75.00 / month
  • 5 Users Minimum
  • $15.00 / user / month
  • Same Access as Pro
  • Subscribe to Teams
there are turning to ah to add a turn around and learned lessons that would get ratings are what you will for sure that the existing applications in a few applications keeping up with the latest version of ruby on rails and upgrading to the next version as soon as it's released it could be a problem some task water in the sub so bored to look at if you think second make your experience with upgrading to ignore rails version a bit easier nifty have an arty check out the guides or ruby on rails dot org i highly recommend it i guess it's kinda give you a lotta different scenarios upgrading from wales five point two five two i'm five zero to five point in even from all her versions of like wells four point two two routes five point zero but with this regardless of the sept said i'd death would recommend reading these to see which version are you jumping from to see what can it changes that you might need to make that specific for the person you're all went to the person that you going to one example is going from rails for two even had this would be requirement of having to be tutu or later so when i'm upgrading a existing application for me or ruby on rails version i do it in different stages and the first stage and oddly of the most important one is they have good press coverage think it has coverage is important because as you upgrade to new rubio roles for just as really the core in the backbone of your application and it's important to make sure that everything is still working so by having the coverage thing you know that the expected functionality is are still working in your business logic is still good the next thing down paid close attention to is the gems because when you upgrade to remove ruby on rails for shit there's a high likelihood that you also get at the optical lot of germs and by updating the gems you could also break some existing functionality to refer back to the previous up with good test coverage so as you update gems you can do them one by one really it just did the bare minimum so you would for sure without upgrading the rails to him again you're going to some the other dependencies as you need to upgrade them because they are locked away previous roles version and then with the configurations i'll make sure that any new configuration options or new styling sped through beyond what else is using any later version that i did the opposite into my application as well then finally had the regression what to buy everything updated it appears to be working go back into it the rules skin of the application make sure all your task of riches are still working if you do have gaps in pass coverage than make sure that those aspects in those areas are still working as well and be on these for examples you might have a lot of other said to him between they could be a dedication that a new wells version has extract added to it so it's no longer available in your application would crash that point hopefully your press coverage will flag of those and incidences in here but some there could be some cases where you don't have to ask are rich rod that area and hopefully to your main your question you would be able to find those and as rebuilding your application there are some differing aspects a yankee the mind to make the process i thought updating your ruby on rails for shared a bed or painless one of those is sticking to the conviction over the configuration this means that mills has all lot of assumptions or ideas of how something should be done if you stick to those the weed out the rails version you'll find that there's a lot less we were to have to do because you're falling to give it to that and using less of their introducing something completely new and hasn't been done before within this app or within rails they will cause you to actively right to barge thanks for example the active job cell was really say wheels for those it no idea and it was something that you would have to migrate to eventually but that could be something that you putting you back on another thing they need to do is to avoid gym center not well maintained that is as important as if you're using a jam and especially if it's a really small and then you're assuming that technical that you might be better off to extract the jet into your application code if you find that the maintain urges no longer making it so with that being inside your code you are then taken on the responsibility of maintaining that that the features and another thing that you can do is keep up to date with the miners in the patches this is important to do because you know what to have your application reach a candlelight and then you have to worry about updating to a newer version so they begged you have the ability to be proactive about and you should also be patient when you upgrade so i would jump right off the boards as in israel's five is released when update my application and just make an effort right away because there's gotta be allotted gens better not get supporting grills fight it if you wait a while then the gym center popular that are being maintained their gentle be updated needed to support the newer version of frills otherwise you might be a really a doctor in you'll find a lot of issues with upgrading and jen zapping compatible when my favorite tricks when i'm upgrading a good deal knows for certain is to death the two different versions so even though there's alot going on behind the scenes and actual jam ruby on rails is so lovely he do to you can get a overview of what's changed within the actual code base saw create a new application of my current version them working with that also create a new version of the one that i'm wanting to migrate to men are rendered death to see what has changed from a base vanilla rails this version to a new rails this version anyway see a few new features introduce like the act of storage or you could see some depth data were they ever move it's a code in favor of something else so what's a bad day rails four to ten application that i want to update to the new bills five to i would i make the jump straight from ailes four to ten rails five to it said on upgrade the major version first then try to get albert king with all my test and then from rails five zero an upgrade to will fight to the video would change from the different versions i might slowly upgrade so from rails five zero to five point in them from five point two five two to get started with the with the differences between rails for two and grills five zero so first make sure that i have the bills version installed so do the judgments on rails then i'll pass in the dash the so i can specify what version know what to install given to the same thing for the rails five zero mandela does create a new template application so first grade the one for the rails for two bananas said before i call him being the command the mehdi be underscores and the rails for sure now want to create i just love this wells forty eight and what sets finish up their mess when then i'll create a wills five zero application then i'll just give them for name embryos five zero zero what sets the end of the wrestling again and if ever and lsd just was see structure in his side rails as strict be you'd see we ever rails for keep him for their rails five hundred for her second outing duty get hit no one has said the rails for dude ten i wanted to press this against wales five zero zero menendez could export is out to file charges called israel's forty eight hand if i died suit at zero and i'll give it the vault stitch in a he then open up a file and with this while you can see that we have a good about everything there is change from the base template rose four to ten to the base template of rails five zero zero to knock the go through all of the different things in here but the important bits i will point out and that's how to tender read the deaths so because we did a bit for the bills for kids in first then the rails five hundred all the mind is is that we see is that the there was taken out on d rails four to ten in all the classes they you see is something else added because of the rails five zero zero the easiest way to remember that or to see what your situation is is what the gym for sure and so we have our mind is that the rails for kids and we have the addition of the wills five zero zero say you'd see some time between this version and mills five zero this op usable a brick is it the fault and acer using too much vessels likely because of the action cable and the need for working with web sockets one addicting several spicer to do it with the inherited from a application job application male or or application record so set of inheriting your models from the active for basic you would inherit it from the application record in that application brighter would have some global settings for all of the models same way with the action mailer now entering from the application male or you could see where these files were created the you get the application create these higher fees as well and yes so weird situations like this with the application layouts and this really did change too much except for the day the troubling to instead of track be untrue it didn't track reload then awesome of the sierras are on reddit that's from the bottom of our assets that push into the top of that so not too many changes there maybe it is the data to relieve stress that said this is a good way to get a general overview of all the different files have been changing sonar example take a look at his upgrading this rails for two to navigation from this version two males five but well priced out that the bills five zero to speak it is kinda beat the same rinse repeat process the board of apollo here so what i'm upgrading a wells application the first thing i do is make sure that as in past so we'll start with the repressed and running because he didn't see that we have seven runs with thirteen assertions so even though we had all full running past when will it all had any idea of what's actually going on here too we have good coverage see him run rate has called real stats this will give you an idea of the winds of good they have within the application then you're good to test ratio based on the role like the good they have for your task it's uncanny in seattle we have about seventy percent quo coverage of our task of that for good lever this really is a dvd can a good indication of it has actually covering the clothing you've written it's owner john fell one at the gym simple called they will set the required to false it will only one to run this in the group past and you should run by no one knew that the sun then in art has held for which is set in two lines of code and if you use a respected this will go on the upper spike over so within the jazz upper what has said the workforce a bulk of their civil code star it's you know we did a runner test will see the same passing gas there will have discovered for pork in an old create a folder with the new rules application called coverage he didn't see that we actually have about ninety three point seventy five percent coverage and if we opened up the index fell within the coverage for we can see all the different files so we have within the application and the coverage that they have since he entered the users controller that there is only eighty seven percent coverage if we look in there he is a entered the creator in the update yeah some gaps you're twenty years you did not say successfully then is going to perform some action so that this was just too difficult road too time consuming to cover that all it does make sure that you know to come back and has these scenarios manually what else coming to do it the worse case you can always write a feature just to cover the situations horrendous example of this would be pretty easy to tell us about a general rule of thumb is to have at least eighty five percent pass coverage over all before i try to upgrade to a major rails version and depending on the complexity of your application this number could really brave resenting several doesn't mean that i try to follow by and so within the jumbo i just said in the rails five zero zero gem he's in the dildo will allow for minor patches to be updated as well they're within the terminal i just want but all of the rails you see that we in no mood to browse five zero six and it was the four to ten because someone the rails five now like he's ready be more than i can call rails second call rails test and it should run much as for me it's immediately you so that we rent or for sarah has areas because we all says it is stretched it out the test should get index and it's something where in the evidence that says they've he just had this huge about the key to using it and that no one had that they met has federal add to this point it said i just want to go ahead and admission into a jump while one bottle they make sure that i'm getting back to green so the verge of all alive in their recommended gym and then they go in just read their within the group has been so what's he had the set and shiny rom bottle after you update your gym foul and so once we've edited and we can color rails passing them and we had a lot more tax output know whether if you look at the final results we have are several rounds thirteen assertions and zero failures and zero enters said this is good we're back to doing but let's look at some good messages that we got so really all that this looks to be around our task that is how they're running so said it is passing in the strict parameters that he explicitly called friends and then you can flash did notice and the message and so the nature that deprecating was around how weird do a drug test and each one he's posing gets in two weeks is now required make you work argument so i'm going to just go ahead and update this because as a joint task wanna make sure that we would do is as much noise as possible so what each one of these i'm going to do is grab it right we're smart and in the parameters that is explicitly called grams as a keyword argument and then i'll close it out as said it does have an id user we don't have the brands and with the hash id user it's an elf we won the rails tested in we should still have a green and now we had no dedication learning to do this could be quiet it has especially if you have large application with a lotta test then you're using deprecating methods but archery it is worth the effort to go to undo so we do run the test your minimizing the amount and always say to focus on the actual issues it's know we wanna look at the configuration files the maintain reserve revealed will spin it as a people putting their roles application they get greater rate has called wales update and this is now a dedicated method of your own rails five zero or later but if you're updating from rails three or rails for application of two males for two then this is what you would use stacey is so more subtle and then cancel the cell then i'll clear the spring and show you what the new version is using said no one a wills five application vehicle rails app update it should do the same thing this ignores are getting into the nitty gritty of the updating the configuration files you see that the very first one big big big as a difference between our rails for two dead end of rails five zero so there are a few different options a good beginner it for health to see what your options are three inches what the options on a cheesy option before death said spanish army with the differences so if you need see that our main difference is that we're just yeah you see that the main changes how were they in the finals it's about that say yes override this one there we get a difference in our routes someone is he with this differences it said here you see that this could be a very dangerous than because at one remove my code that have format application so on what to avoid his overriding the final so i need a find out how can i get their recommend information this case all the added was a common but policy when i need to do to keep my existing information but maybe have a big new ones at and as well seventy eighty page for help so why tell override and do not over right a skynet all right everything is the deathly want to avoid this one being quiet or you get the death so this case i'm a copy to acquit board be important because then i might need and then i'll come back into this a case that then this case but for now when it had no in their we have learned to fake application the skip the deaf on this one again we're just deal with comments the one thing that they took out was the active record raise a transaction all call back set to true they were made this and the bills five zero make it because it's a global the fault set to true know if you want to override the singer would have to explicitly said it falls on archer bad men in this seems to be that omar me some just an override it their sacred see a whole file i know that this one is going to be distracted because that's from putting all the secrets from application and they say no to this one it within the apartments your development production contest those are most likely going to be configured pretty have we buy you and it's something that you will want to caution on because this is good i have a lot of changes potentially this is gonna be way too many changes for me to digest just from reading here today good decision whether you can refer back to your death while they you created and with that death while they you created earlier in the episode with a reference back to their to see what the changes or if i'm really needed to copy everything out of here than at the disco brother from the rules five hundred app or i could just run the rails app update again they deserve read this one file so let's say avocado all the information i needed extracted out that a change in now i want to just over it as an it is good and override it and same thing for the production since and say you take the development and also for the past so now we're at the cookie serial wiser so if we wondered if one year i see that the descendants of comments and there's no other changes we've been over at that but that deal their rep parameters what this trap parameters accuracy that the main difference here is that they have remove this check in in this case at all know much about the rant parameters so i wouldn't trust that they know what they're doing here and i'm going to just take their suggestions and override and then under the bed for the rails this is one that i'm very rarely have tickets much my application but if i do then how would want to make sure that they go what changes that made them know about that film but this case and they take the bills five suggestion on how they're loading rails the will go from there and then same thing with the break would overrun fat and for the band set up typically with the dead set up you can add this customize allegheny for your application so how would probably skip this one and had no and we're done so once we're done very next sing them going to do is add one to run my real stuff sig end to make sure that there's no break and shave says and we're still going and so now that we've gotten park has covered still running we've updated are gems just make sure that there's no complex anymore we've updated or configuration files as good in brief fresher page to see if we are now on our new wells version here we are so we could stop to this point we have very good pass coverage that we have our application running we but they they're considerations one graduate to go ahead and just make sure that this is still working as it showed in each way that created my user is sold the week users and eddie users and that show users so that's like my applications working the way it's intended glover on that the to stop here he will we could this is breaking one my rules are not following the convention over configuration we sell within the death note but we also saw all in the upgrade guide that the rails five percent started using a new standard configuration so with him i used to model in hurting from the act of record pace is no longer their preferred way bill and and if you remember from reading through the death of research for the act of repair paste you see that they now prefer the application record that matches under the models application record daughter be someone up all of this method of how they're do with it so within the user be what is called this the application record though and hair from they're within the models for all create a new file called the application record got a b and then now based in the application record inheriting from the active record and this is one thing that they've added in as deep all these self died and shot class equals true and as we make a few changes and a good run the test again to make sure that everything was so we're done appropriately in advance the cell from one final tip as you would do this you might sell that i just rented task several times menu week when i use of the like carter spring to do this mess simple answer is is a given to be updating gems configuration files and oh by the settings one out there we're upgrading from a cold rails for shit to ignore when an eagle one york has weed or your tools to get a new way an allotted heinz they will getting away because it's loading from memory and it's oddly starting so you'd better be paid you're using a new gym for shed or a new configuration file celebrity all good listener didn't memory or spring or guard is getting a new way of putting yourself in abilene passenger to be struggling to see why is it as failing so if you do want to use one of those then just make sure they just came in the back of your head if you do have a feeling that sticky be a false positive an hour which is coming here and run the test manually oh that's all for this episode they keep watching