So it’s finally here! After three beta releases and several weeks of discussion, Ruby on Rails 5 was officially released on Friday. It’s the biggest release from the Ruby on Rails community since June 2013 and comes with an impressive range of features and changes.
Here at CareerFoundry, we’re pretty excited for two reasons: Firstly, we’re busy implementing these features into our own platform. Secondly, we’re very proud to announce that our Web Development Course materials have already been updated to include the latest features and changes. What’s more, its developer community has ensured that Ruby on Rails 5 is not only loaded with new features to keep it up to date and interesting, but also that the framework is ready to evolve and embrace the future of technology.
Not Sure What Ruby On Rails Is?
If you aren’t that familiar with Ruby on Rails, it’s a web development framework that’s more than 10 years old now. Many well-known companies use it to run their websites, such as AirBnB, GitHub and Hulu, to name just a few. Familiarly known as “Rails”, it’s not only fun to use, it’s something that is quick to learn and has many features that developers need to build web apps. It’s a powerful framework that can handle a number of tasks at any given time.
Why You Should Be Excited About Rails 5
**But what’s so exciting about Rails 5 and why is it so much better than Rails 4.2? Well, there are several very interesting changes, some more dramatic than others. Find out what to expect in this short video: **
We’ve made a list of what we’re most excited about with this new version and we’d love to hear what you think! Have you tried it yet? Disagree with this list? Be sure to let us know in the comments at the end of this post.
Real-time data with ActionCable
ActionCable adds real-time features to Rails right out of the box. In the past, if you were thinking about which framework to use for a web app that relies on real-time features, then more often than not you’d be advised to use NodeJS and SocketIO or a comparable framework. This is because these frameworks enable you to add a variety of real-time features to your app such as chat messages or notifications.
Well, not anymore! ActionCable leverages Websockets to keep open connections between the user’s computer and the server. This way you can send data from your Rails server to all connected users and update whatever they see in their browser. The most obvious use case would be something like a chat app.
Want to learn more about it? Check out the official example app (it requires you to set it up locally). Basecamp, who make up the core team developing Rails, is the first and most popular web app using ActionCable for real-time communication among users.
Use Rails Just For Backends With API Mode
Another big change is API mode. Traditionally, Rails is a framework for web apps that runs entirely in the web browser. It makes it very simple for you to build powerful and robust backend logic to interact with data and to integrate it with the frontend of your web app.
Nowadays, however, there are many use cases whereby the frontend and backend of an app are separated. Most commonly this would apply to smartphone or tablet apps. For example, you write your native app for Android or iOS but you want it to interact with a server to save data online. If this interaction is all you need your backend to do, you don’t need any HTML pages. You simply need a solid backend your mobile app can connect to.
Well, with Rails 5 you can do exactly that.
With Rails 5 you can generate your Rails app in API mode which means it will be generated without any of the things you would normally need if you were to run your Rails app directly in the browser. This includes, for example, the “views” and “assets” parts of Rails apps. You can then communicate with Rails through “RESTful” links and transfer data in simple JSON.
If you’ve used Rails before, you’ll have to unlearn using the “rake” command in the terminal to run tasks. In Rails 5, you can do everything with “rails” right now. This means, for example, “rake db:migrate” is now “rails db:migrate”. If you’re new to web development or have just started our Web Development Course, don’t worry about what this means. All you need to know right now is that this change will simply make things much easier for you when you come to learn this part.
What Else Is New?
Rails 5 includes a whole number of big and small changes. Check out the full changelog here to see everything that’s new. But just to give you an idea of some of the other things to look out for, here are a few more to keep in mind:
Rails has a new logo and welcome screen when you first create your app
Rails uses Puma as the default web server now instead of Webrick (some articles online are outdated and suggest you need a multi-threaded server such as Puma to run ActionCable. That used to be the case with early versions of ActionCable but that’s not necessary anymore. You can even use servers such as unicorn)
Turbolinks 5 promises to load your pages much faster than before
Use built-in helper methods like “on_weekday” or “on_weekend” to check whether a date is a weekday or on a weekend
[What’s your favorite part of Rails 5? Did we miss something that you think is essential on the list of most important features? Please let us know in the comments.]
How To Upgrade To Rails 5
Whether you want to start a new Rails 5 app from scratch or upgrade an existing Rails app, the Rails Guides website is always a great place to start looking for instructions.
But to get started right away, there are only a few simple commands you need to run to get the latest version of Rails up and running on your computer. If you already have a RVM, Ruby and an older version of Rails installed, there are only a few steps you need to take in order to upgrade your local Rails version:
You have to update Ruby, your gem manager, and the gems you already have installed. If you type rvm list in your Terminal you will see the Ruby versions you have installed. The = will show you the version you are currently using. Type in gem list , now. Here you see a list of all the gems you have installed. In that list you should see Rails, for example.
Let’s start by installing the most recent version of Ruby (Rails 5 requires at least Ruby 2.2.2 or higher). In your terminal run: rvm install –latest.
This command will use the Ruby Version Manager to download and install the most recent and stable version or Ruby. At the time of writing it’s 2.3.0. To use the version you just installed and turn it into your default Ruby version, type in rvm –default use 2.3.0.
Your installed gems are all associated with a Ruby version. If you type in gem list now, you should see a much shorter list of gems. But don’t worry, just type in rvm gemset copy 2.2.2 2.3.0 (replace “2.2.2” with your previous Ruby version and “2.3.0” with the version you just installed) to transfer your list of gems from the old version to the new one. This might take a few minutes.
Now you have the most recent Ruby version. The next step is to update your gem manager. To do that just type in gem update –system.
Now the last step: Update your gems. Run gem update to update all the gems in your list of gems. This should include Rails. To be sure type in rails -v.
And presto - you’re all set and can now generate your next Rails app using Rails 5. Just navigate to the directory where you want to save your Rails app and type in rails new my_app_name.
Rails 5 is great news to both experienced and amateur programmers. It introduces some great new features such as ActionCable and API mode which offer us many more opportunities for building even more types of apps with Rails.
With Rails 5 you no longer have to make compromises, as you don’t even have to think about different frameworks if you’d like to have an API-only app or include real-time features. In a web where real-time data updates and speed are both increasingly important, the team behind Rails has made sure it’s a solid choice for modern app development for years to come.
That’s why at CareerFoundry we’ve already incorporated these changes into our course material to give our students the tools they need to build modern and performant apps while benefiting from all the usual features that come from developing with Ruby on Rails - such as short development time or simplicity of code.
So you can get straight out and start experience Rails 5 for yourself, we’ve compiled a list of useful resources below for you, from the official announcement to video tutorials and guides. We’re excited to hear what you think!
- Official blog post announcing Rails 5
- Video by one of Rails’ developers giving an introduction to Rails using Rails 5
- Using ActionCable and authentication with Devise
- Video tutorial and introduction to ActionCable by one of the Rails developers
- Official example app for ActionCable
- Upgrade your Rails Version (Rails Guides)
What You Should Do Now
- Get a hands-on introduction to web development with a free, 5-day short course.
- Become a qualified web developer in 4-7 months—complete with a job guarantee.
- Talk to a Career Advisor to discuss career change and find out if web development is right for you.
- Learn about our graduates, see their portfolio projects, and find out where they’re at now.
If you enjoyed this article then so will your friends, why not share it...