Gems I Could Not Live Without
Ruby on Rails is an open source, free framework for rapidly prototyping and developing robust, scalable web applications. Ruby on Rails is excellent all by itself, but one of the greatest parts of the Ruby on Rails community is the extensive list of code libraries, plugins, and extensions, often shortened to just: Ruby “gems”, hosted on RubyGems. As of writing this, RubyGems reports that it is hosting over 28,000 gems!
That is not a trivial number. That is 28,000 code libraries that you don’t have to write to get your application up and running. That is hundreds of thousands of lines of code that have already been battle-tested in production applications for you. That is getting your application developed and ready for market faster and more efficiently, by re-using code and not re-inventing the wheel at every turn.
But there’s still a problem with all of these gems… How do you find out if a feature you want already has a gem for it amongst all of the options? Sometimes they have weird names. You might think, “maybe I am just not searching for the right word?” Even we have a tough time searching through this treasure trove of code, so we keep a list of Gems that solve common problems well.
Here are some of our favorites in use on many of our current client’s projects (and our own projects):
- Devise – an authentication plugin for your app that lets you get users signed up, confirmed, invited, passwords reset, etc.
- Pry – an awesome tool to debug ruby code.
- RSpec – TDD (Test Driven Development) framework that provides the ability to reuse code much more effectively than the default Test::Unit framework that comes with Rails.
- Cucumber – An BDD (Behavior Driven Development) integration testing framework where the tests are written in short paragraphs, not code. Very easy to pick up, but requires more overhead and executes slower than Rspec.
- Ancestry – Do you need to link objects in your app together in a tree-like fashion? Just use Ancestry and leave the complicated SQL queries to this guy.
- Kaminari – Pagination gem for Rails 3. If you need to “Next Page” buttons, this is the gem you need.
- Foreman – will start up any local development servers with one command and in just one terminal window!
- Unicorn – replacement development web server for the default Webrick. If your app’s urls get too long, Webrick will error making it impossible to test your application. Unicorn is simply more robust as a local development web server than Webrick.
- HAML – a replacement for the built in erb template engine. Its a DSL (Domain Specific Language) where you don’t have to close HTML tags or Ruby blocks! The closures are implied by the spacing on each line that this engine enforces. That means you worry about the content on your apps website and this template engine deals with the tedious process of generating clean HTML.
- Slim – Another replacement for erb, even less typing than HAML without becoming cryptic.
For finding gems on your own, Ruby Toolbox is a good site that tracks popularity of gems across different categories, like: “E-Commerce” and “Calendars” for example.
Do you have some gems that are “standard” in your toolbox?