Why you should give Rails a try in 2019

Remy Kaloustian
Codelitt
Published in
6 min readJun 24, 2019

In this article I want to present a couple reasons why Ruby on Rails is still a reliable and efficient framework.

Ruby is easy to learn, read and understand

One of the first things that you may notice while learning Ruby is that the syntax is extremely basic and simple. Indeed Ruby is a language that was made for simplicity and readability. Its own creator said that it was made for productivity and fun. If you try Ruby it is almost guaranteed that you will face no problems concerning code comprehension, and that is a (first) good reason to give rails a try. Just to give you an example, here is a class in C++ and Ruby:

As you can see, in C++ we have a little more symbols than in Ruby. While this difference is not huge, in the long run it might make a difference, for example when you are on a 50+ files project. Not only that, but the code in those lines is less prone to confusion in Ruby, especially from a beginner’s viewpoint. A beginner may get confused when seeing #include <bits/stdc++.h>, using namespace std;, private or public, and the << operator which will need its own explanation with streams in C++.

Of course there are other languages to choose from, not just C++, but that was just to give you an example between a not so straightforward syntax and a clear, simple, basic syntax, to demonstrate how Ruby tends to minimize the headaches.

It’s fullstack

One of the wonderful advantages of a Ruby on Rails project is that it is a fullstack technology, meaning, it takes care of the front-end AND back-end. The back-end is handled by Ruby files, and the front-end is made of HTML, CSS and JS files. This is definitely a plus because it keeps everything in the same ecosystem, thus avoiding having to use different libraries for just basic features (if your project is big you will probably need libraries at the end of the day anyway). What makes this fullstack aspect even more convenient is the mapping between the controllers from the back-end and the views from the front-end without any additional code. With rails, it feels like everything automatically clicks together.

Another great aspect is if you feel limited by Rails, you can add another technology on top of it, but that’s for the next part…

You can add a front-end framework

Imagine the front-end of your Rails app is significant, you have a lot of components you can reuse and you think JS is limited in that sense. Wouldn’t it be better if you could work with React, Angular, Vue? With Rails, you can. In fact I don’t even have to redirect you to some specific websites, through some forgotten article, just type “add React/Angular/VueJs to rails” and you will find a ton of articles telling you how to do that. Not a lot of frameworks allow you to do so and that is just another great plus of Ruby on Rails.

So far we have seen that a project on Rails is easy to start/grow/understand, is self-sufficient and has front-end/back-end mapping to make things simple, and can be improved with a front-end framework. This alone could be enough to make you lean towards Rails. If you are still hesitant, Rails has other advantages for you.

Selecting from DB is easy

You learned that Rails has a back-end part, but do you know if it’s convenient to interact with the database? Have you rehearsed your SQL requests yet? No? Perfect, you won’t need

them, because you can manipulate the DB directly from the back-end Ruby files WITHOUT having to write SQL requests. Let me show you how it looks.

Imagine you had a User table. Here are some operations you can do:

Creating a User

Selecting a User:

Updating a User

As you can see, no need to connect to the database beforehand, no long SQL requests, it is very short, easy to use and understand.

The console makes the DB interactions quick

Still with the database, let’s talk about the console. If your app has a database, you would want to have some kind of access to it right? Fortunately for you, Rails comes with a console that allows you to do all the operations you need in a DB. For example, if you want to add some Users, you don’t have to write this in one of your back-end files that will be executed after you launch the app, you can just do that from the console. All updates/insertions/deletions/selections are possible from the console and give you a much more direct way to interact with the database than having to integrate that in your app and then remove it when it’s done. It is also useful if you are joining a project and want to see the different tables and their attributes without having to go through every feature or every file.

A lot of stuff is generated

With Rails, you can generate a lot of files. For example, in the back-end we have what we controllers, which is a file dedicated to a specific route in the app (http://yourwebsite/myfeature will be taken care of by the myfeature_controller). After executing generate controller myfeature, you will have created:

  • A controller file myfeature_controller.rb
  • A view file myfeature.html.erb
  • A test file myfeature_controller_test.rb
  • A coffeescript file for dynamic front-end management myfeature.coffee
  • A sass file for front-end styling myfeature.scss

And that’s just after running only one command!

Rails always has your back when it’s time to generate controllers or migrations (files for database modifications). In addition, the automatic mapping that is done behind the scene gives the rails ecosystem a great sense of cohesion, which, while it may seem confusing at first, will make sense later on and will help keep the project/naming coherent.

The documentation is well detailed

If you need help on anything concerning Rails I would suggest the documentation and the guide. The documentation is really helpful, with a lot of different examples to show the different use and parameters of functions (for example, here is the documentation on the redirect_to method https://api.rubyonrails.org/classes/ActionController/Redirecting.html ). The guides that help you start on Rails is also well done and will help you become efficient quickly with this framework. Here are some links to give you an idea:

The documentation: https://api.rubyonrails.org/

The guide: https://guides.rubyonrails.org/

Fast implementation

All the previous points lead us to another advantage which is far from negligible: Fast implementation. The way Ruby on Rails is done, the way you use it, the language it uses, the tools around it, all of that is a great …when you want to implement features quickly without working 40 hours a day. The easiness of the syntax makes you learn, progress and add features faster. The fact that it’s fullstack means you don’t have to master another piece of technology and reduces your learning time. Adding a front-end framework will allow you to create more structured JS code(or even dynamic code) and you can have components that you reuse, thus limiting code creation/duplication. All the interactions with the database will be quick and simple thanks to the ActiveModel that Rails uses, which means no big requests embedded in strings. Encountering a bug? You can use the database console to check what is happening or look at the multiple online resources.

Conclusion

I had no idea Ruby on rails existed when I started programming as a job. However, without any knowledge of this framework or the Ruby language, I was able to quickly learn the paradigm and consider it to be one of my favorites (if not my favorite) tools (I’m no genius so I think you can do it too). It is one of the only tools I have worked with when on multiple occasions I said to myself “Woa, that stuff is neat.” But at the end of the day you use

--

--