Discover the world of Ruby frameworks

2015, Sep 21    

Lots of developers who start their web development journey choose Ruby on Rails for their first projects. That’s a good choice in my opinion - you can get your app up and running quickly and quite easy. It’s really fun and lots of people enjoy this fast way of development. Problems start to occur when one does not have enough knowledge about what’s going on behind the Rails scenes - the app is growing and the control is getting more and more limited. Everything ends up with a big mess which is hard to clean up. If you’re a beginner and have some Rails projects done, I think it’s a good time for you to take the next step and try something else. You can learn a lot about how does Ruby and its frameworks work (and understand Rails better), by digging into lower layers, down to middleware or even more. As my grandpa said: you can do more and choose better if you know the alternatives. So let’s take a quick look at Sinatra, Cuba, Padrino, Lotus, Roda, Trailblazer and Volt!*

Let’s start from the beginning - Rails is a very good and mature framework used widely around the world. Obviously, it’s not the best solution for all your projects, even if you know how it works from scratch. Personally, I like the magic of Rails happening in the background - it helps a lot to deliver the working code faster. In spite of that, I’m pretty sure that there are much more options in the world of Ruby frameworks, that can also bring you a lot of fun and help you understand some things better. Let’s start the quick brief of this stuff.


“Cuba is a Ruby microframework for web development.”

You can find this sentence in the project’s homepage and it’s the essence of this framework. Cuba has less than 200 LOC and it provides a really minimalistic set of “features” that you need. It’s (of course!) built on top of Rack and actually does one thing - handles the HTTP requests. Thanks to that it’s really fast, stable and gives you great flexibility and control over your app. The cost of that is obvious - you need to write more code to get things done. It’s definitely worth trying if you’re not a very beginner in the web.


Roda is a fork from Cuba by Jeremy Evans. The framework itself has a small core and it’s desired to use plugins instead of tons of internally implemented features. Thanks to that you can easily avoid developing a messy monolith while writing an app. Actually, I have just started to use Roda in one of my recent projects so I can’t write down too much of what I’ve experienced in person. For me, one of the most interesting features in Roda is routing - you’re not using a standard routing list with Roda, but a simple and readable routing tree. That’s actually the main difference between Roda and Sinatra. Another interesting thing in Roda is the way it works in production - it’s freezing the most of the app’s structures and thus is immutable. Roda is really a quite interesting player on the market.


To be honest - you should already have heard about Sinatra as I think it’s the second (guess who’s first! ;-)) most popular Ruby web frameworks. Actually, I would rather call it a DSL. It is a lightweight project and much more simple than Rails or Lotus. That allows you to create web apps with great flexibility and minimal effort. There is no ORM there (what does not mean you can’t use ActiveRecord for example), no controllers or models layers - it’s all up to you how you design and implement your app structure and features. Compared to Cuba it gives you some more basic features ready out of the box, but it’s still far away from tons of helper methods (etc.) delivered to you by Rails. It’s not a ‘two click’ framework which allows you to get a quite complex app running in one evening, but I like Sinatra and I learned a lot from it. I really recommend you to play a little bit with this framework if you haven’t tried that yet.


I think we can assume that Padrino is simply a Sinatra-based framework with lots of Rails-like features. Its functionality covers lots of topics similar to RoR: routing, generators, views, caching, mailers, tag/form helpers etc. Padrino has not so many features as Rails, but it should be enough to launch a medium-sized app quite fast. In my opinion, Padrino is worth considering to use only when Sinatra is too lightweight for your requirements and Rails seems to be a too heavy weapon for your project.


Lotus is a relatively fresh, “full-stack ready” project started in 2013 as an alternative to Rails. The main goal of Lotus is to use POROs (Plain Old Ruby Objects) rather than to learn another DSL to deliver your web app. Lotus contains the following micro-frameworks, that smoothly work together: Model, Router, Utils, View, Controller, Validations, and Helpers. You can use all of them or choose which one to include in your project, that gives you some basic flexibility when planning your app. If you like “The Rails Way” and are satisfied working with RoR, you probably wouldn’t like Lotus. If you’re tired of “The Rails Way” and want to try something else, Lotus is a good choice for you.


When you click on the link above you can find the following info: Trailblazer is a thin layer on top of Rails. It gently enforces encapsulation, an intuitive code structure and gives you an object-oriented architecture..

In my opinion, Trailblazer is a very specific project. I like its approach that helps you keep your (Rails) app more clearly structured and object-oriented, with no Rails-specific issues like fat models etc., but to be honest, you can achieve this, and much more, without Rails. Personally, I think that putting an additional layer on top of Rails is too much. Imagine that you’re adding even more layers on top of it - you’ll probably become overwhelmed by everything that’s happening in your app.


I’ve left Volt to be described in the end as it’s quite different from the others. It’s in fact built on top of Rack, but the way it works is rather uncommon if you compare it to any other Ruby framework. The greatest thing about Volt is that it compiles your Ruby code to JavaScript via Opal. It thus allows you to write a rich, dynamic web apps without writing the JavaScript itself. Volt works on both server and client at the same time, so it gives the users a true feeling of working in real-time. It’s a great alternative if you’re using Ruby for back-end and lots of JS in the front (Angular, Backbone, Ember etc.). The only disadvantage of Volt that comes from its unusual approach is that, for now, it supports MongoDB only. As it’s very hard to use complex, nested JavaScript Objects in SQL queries I’m afraid we have to wait a long time for a MySQL/Postgres adapter for this framework.


This post is not a guideline through all of the frameworks listed above and how to use them. It’s only a quick brief that shows you there is much more than Rails in Ruby web frameworks world. As a professional or hobbyist Rails developer, I believe you should taste something else and you can find some interesting positions for you right above.

* Please let me know if I missed anything!