The more I develop with Ruby on Rails the more I feel that I’ve wasted a lot of time re-inventing the wheel. There’s a lot of things that Rails gets right, the following list is a short summary of some of the many things that makes it a great tool.
Generators get you setup fast
Rails generators help to quickly mock out your application, moving from nothing to a clickable wireframe with a database in minutes to hours instead of days. “rails generate” is a great tool helping you to create your base template classes for any instance you may have in a project, as a bonus most all generators take additional parameters to complete the code within. When creating model instances the command a
rails generate model comment commenter:string body:text will create a new database migration the model class for it as well as a default set of test cases to get you started.
Multi-environment Setup is part of the package
By default Rails is ready for a multiple environment setup. Using the environment variable RAILS_ENV, which can be set via command line on any linux system. Using the built in rails webserver via “rails server” will use the Development configuration by default. Being *database agnostic you can also feel free to use sqlite, or whatever local database you have configured. Not having to configure this setup every single time is a huge timesaver, typically you’ll find a config file full of else if statements configuring via domain names in most multi-environment projects.
* be careful when using database plugins and gems, many of them may use database specific functions that can cause you issues when using different databases in multiple environments. Whenever possible its best to use the same database in all environments.
Rails will automatically generate your starting tests for you, this applies to both controllers and models. One of the things that really pulled me to rails was that from the very start most tutorials perceive testing as “how you write code” instead of an afterthought; to agile developers this is an important aspect of writing code. When the test stubs are generated for excuses for not testing are eliminated… as if there were any excuses to not test in the first place. If you don’t like the default testing framework and you have a different one in mind for your project if the chosen direction provides generators you can swap it in and still maintaine the same functionality, RSpec is a popular choice over the default testing framework.
Change is expected, Rails embraces it
“Responding to Change” is one of the 4 tenants of the Agile Software Development Manifesto and databases are probably the most painful part of following this. By using migrations Rails handles database changes with ease, instead of writing SQL you write Migration Objects, which are individually time stamped and kept track of per instance. If a migration goes wrong you simply *roll it back to the last stable version. Using migrations its also easy to debug the project at different revisions, by simply checking out the code and running
rake db:migrate your working with the version of the database the code expects and on to resolving issues.
The rails ecosystem is Ripe with people who love trying out new things, Rails supports technologies such as Coffee Script, Less CSS, and many many more thru gems. Instead of having to build these from scratch as many of these additions require pre-processing, the rails Gem will automatically handle it for you, adding to the list of one less thing you need to worry about.
*migrations will NOT backup your database so any time a migration will remove data its a good idea to back the database up first, if rolling back the database or code would cause your application to no longer work
Like Maven provides for Java; Bundler provides for Rails. Dependencies for individual projects are easily installed on your machine via
bundler install. No hunting around for packages you may or may not have, bundler automatically finds and installs them for you saving lots of time.
In closing; Ruby on Rails is more than just a web framework. Ruby on Rails is also a collection of utility and support tools that allow developers to focus on what’s important Solving Problems and pushing software. For Agile development few alternatives come close to the breadth of thought that has put into Rails. Spin-up for new project members is fast, database management is easy, and integrating the latest and greatest web technologies is a easy. Using rails you can iterate fast, and deliver more value to your clients by focusing on what matters most.
If Ruby isn’t your thing you can also take a look at Django, written in Python it is probably as close as you can get to Rails without writing Ruby, but who wouldn’t want to write Ruby?
Mentioned in this Article: