Leaving Sinatra and getting on the rails — my first week with Ruby on Rails

After a mere week of bootcamp learning spent familiarising myself with Sinatra I have now graduated to Ruby on Rails. In this blog post I’m going to give my first impressions of working with Rails. Being new to Rails it’s not possible for me to give a detailed technical analysis.

For those that are not familiar, ‘Ruby on Rails’ or simply ‘Rails’ is a server-side web application framework that follows the MVC (Model, View Controller) framework. Sinatra is also web application framework which was designed with the purpose of making it quick and easy to create web apps in Ruby.

The main difference that is instantly obvious is that Rails is a lot less verbose than Sinatra when it comes to the amount of code required to write an application.

Application Controller Written in Ruby
Controller code for identical application written using Sinatra

Having spent even more time with Ruby I’ve learned that various ‘helper’ methods exist that can cut the amount of code required down to even less than I first thought possible.

Rails has many such ways to reduce the effort required on the part of the developer and it’s possible to write very short elegant pieces of code that have the desired effect whilst still making sense to the person reading them. Sinatra on the other hand requires more code to be written to achieve the same effect.

One particularly nice feature of Rails are the Rails Generators which will create basic app frameworks with a single terminal entry. The frameworks do not write complex code but act as quick templates to get you started so you don’t have to repeatedly code the same thing every time you want to create a new app. This is helpful to anyone who is new to the MVC pattern and who wants to stick to standardised file structures.

It’s advised that all automated code generators are used with care as they can and do generate a lot of files, which, if you’re not intending to use them will sit in directories taking up useful space!

Finally, Rails also comes with a wealth of written resource which makes it even easier to navigate. The official Rails guides are a great place to start: