Rails Upgrade Challenges And How To Deal With Them

As you may already know, Rails 5.1 has brought a lot of new and cool features. You can find a complete description of the release notes here. The upgrade has addressed various performance improvements and security issues. And, of course, all the deprecated code has been removed. However, this article is not about another new version of Rails. The community has already published a ton of posts about that. Instead, we’re going to talk about the challenges you may encounter when upgrading a Rails application. By the way, here are some useful links:

 

The lack of test coverage

Of all the challenges you may encounter during the upgrade process, the lack of test coverage is probably the most painful one. Still, even if you did receive a project that hadn’t been properly tested, there is no reason to panic. Take a deep breath and start with writing tests for the basic functionality. Doing that is the least you can do to ensure the integrity of the upgrade process.

Using obsolete routing in old apps

In some apps, routing may be organized through “match”. In addition to being rather old, such an approach has a negative impact on the performance of the application. The best solution here is to rewrite the routing. But before you jump into doing that, you should know that it’s a complex and time-consuming process. So, be sure you have a clear understanding of the exact steps to take.  

Asset Pipeline and manifests

When it comes to manifests, most of the guides insist on using a straightforward approach like the following: “...paste this piece of code there”, “...gather everything in a manifest”, “...now that you have UJS, you can use it”. Despite being consistent, guides like these may not always fit in your particular case. In older versions of Rails, assets are usually poorly structured and as a result organized differently. So when you start gathering your manifests, be prepared to find styles and scripts in the most unexpected places. And, if that’s the case, simply piling all the assets won’t be the best idea. What you should do, though, is make changes gradually and check results after each iteration.

Gem dependencies

If your Rails application is dependent on a couple of third-party Ruby gems, there is a chance you may not be able to upgrade right off the bat. Ideally, gem maintainers are supposed to test their project with a pre-release Rails version so that the gem would be fully compatible by the time the final version of Rails is released. However, in a real world setting, gems that are developed less actively often take more time as well as testing to release.

Ensuring app integrity

There is no point in using the most innovative technologies and up-to-date style guides if the application ultimately fails to work as expected. The more application updates there are to roll out, the higher the risk is of skipping some bugs is. This is especially true for applications that are being used by tens of thousands people daily. We’re talking about online stores with wide product ranges, dozens of catalogs and other complex functionality. In such case, one tiny mistake can easily cause permanent damage leading to significant financial and customer loss. That’s why it’s highly important to take additional measures to ensure application integrity.

 

  • Be sure to test your application both on the test and the production servers.

  • Use regression testing to check the basic functionality of your app. If it’s an online store, the primary focus should be placed on the payment and the registration features.

  • If you are working on a big project (e.g. a high load website), try using Xenu. It’s a simple utility that allows you to go through the website to detect pages that fail to open.  

  • In order to avoid the situation when you find out about bugs in the nick of time, use services like Airbrake and New Relic to monitor the status of your server. If there is a bug or any other issue detected, you will instantly receive a detailed notification about it and thus be able to prevent the unpleasant consequences promptly.

In conclusion

Upgrading is an essential part of Rails application maintenance. Ideally, you should always keep your application up-to-date. After all, it’s the only way you can receive all the newest bug fixes and security patches. However, every application is different. So, the first thing you need to do before actually going for an upgrade is decide if it’s really worth the hassle. If a newer version of Rails comes with features that can clearly benefit your application, then there is no reason why you should hesitate. But if you’re planning to upgrade only for the sake of being ahead of the curve, there is a big chance your efforts may not pay off in the end. At the same time, this doesn’t mean you should avoid the procedure at all. You can read about the consequences of delaying an upgrade in the article by this link. Briefly, the older the version of Rails you use and the longer you wait to upgrade, the more vulnerable your application becomes. What’s more important, this can lead to things like reputation damage, loss of time, potential loss of control over the development processes, legal complications, loss of customers and more.

 

Computing vowel frequency with R

Can you please give me a hint on what's the best and easiest way to compute the absolute and relative frequencies of vowels in a string using R? I guess the source code is a bit different from what [Read More...]

Сounting vowels in javascript

I use this code to search and count vowels in the string, a = "run forest, run"; a = a.split(" "); var syl = 0; for (var i = 0; i < a.length - 1; i++) { for (var i2 = 0; i2 < a[i].length - [Read More...]

Count no of vowels in a string

I wrote a program to count no of vowels in a string but its not efficient or optimized code. Moreover it will not check caps vowels. #include<iostream.h> using namespace std; int [Read More...]

Basic Linked List operations in C

I am creating a program to perform basic linked list operations. Right now i have wrote the code only for inserting the node at the front. I ran my program to see its working or not but the program is [Read More...]

Strange $_SESSION var behivor in PHP

I've been struggling with this for 2 days now. the code below works perfect on my localhost (WampServer Version 2.5, Apache v2.4.9, PHP 5.5.12) but not on my host server. I am trying to pass $_SESSION [Read More...]

Apt install with ansible

I use ansible scripts to set up my environment (Ubuntu) in Amazon EC2 and a vagrant box. Then I try to set up the same environment at GermanVPS (Ubuntu Minimal). Installing packages with Apt doesn't [Read More...]

Use Superagent with A+ spec?

How can I use Superagent but with the Promises A+ spec? I'm working on a project that uses both Superagent and Bluebird and I would like to use the .then() syntax but can't figure out an easy way to [Read More...]

scheduling a command to execute right after a *running* command finishes?

Sometimes I will run a command 'foo', and it takes way longer than I expect it to. If I were to rerun it, I'd probably do something like: foo && mail -s "foo is done" [emailprotected] ..so it [Read More...]

compile phalcon php openshift

Im trying to compile phalcon php on openshift using this http://www.sitepoint.com/nginx-php5-5-phalcon-openshift/ Everything is ok, but I cant finish compilation of module: There is no error just [Read More...]

google map api nearby place search

I am using the Google Maps API places library to use the nearby search feature in my Worklight application but only the map is displayed and the nearby places is not shown.Please help me with [Read More...]