My favourite Ruby gems & services

With Ruby and Rails, you have a great eco-system in which to build fully functioning webapps quicker.


I love Ruby and I love Rails. It’s not unconditional love — there’s still lots of problems — but for me, it’s by far the best language and framework out there due to their readability, ease of use and the sheer speed in which you can make complex sites.

There’s a huge number of gems and services out there and for beginners, the good ones are hard to find. There’s also the temptation to write your own code to do something that others have already created and made open source because you didn’t know about it.

If you know of any gems or services that are great and I’ve missed them out, please add them into the comments.


Helpers

One of the first things I always add to any Rails project is simple_form as it’s far better than the default Rails form helpers which in my opinion are fairly useless. I reckon simple_form should be integrated into a future version of Rails as standard.

For pagination I use Kaminari as it’s super easy to install and use. For adding Markdown to longer text, RDiscount is pretty good. For pretty URLs I use Stringex as it’s better than the default “parameterize” in Rails and also handles non-roman characters well.

For tagging, there’s no need to do it from scratch as acts-as-taggable-on has loads of in-built features such as related tags and search. For date parsing, Chronic is pretty amazing and fully featured. In case your users are likely to accidentally delete things, Paranoia can let your users undo.

Geolocation

Another gem is I think is incredible is Geocoder. As someone who worked at a business review site years ago, this gem would have saved me three months of coding. The following code example shows how powerful it is.

Business.near(“Islington, London”)

How hot is that code? If code could turn me on, that would definitely do it. On the front-end, I like to use leaflet.js with Mapbox to have more control over how the maps look.

Administration

For any kind of content management, I use Active Admin— again, another gem that’s ridiculously easy to install considering the power that you get with it. The down side of Active Admin is that it’s still in the works for Rails 4 so you have to get the development version which occasionally has bugs.

For customer management (e.g. queries, newsletters, auto-emails, etc.), I usually use Intercom. It is a paid service but it is definitely worth the $49/month that you’d need to spend. There’s a few features that they could add to make it killer but it’s very good as it is.

Uploads

For image and file uploads, I always use Paperclip. Again, super easy to install and it even comes with image resizing and cropping as standard (as long as you have Imagemagick installed — Mac installer here, Windows installer here). As I use Heroku (more later on that), I add my file uploads to Amazon S3 with the aws-sdk gem. There’s a good guide to Heroku, Paperclip and S3 here.

Search

Adding search to a site is hard work and isn’t an easy job so it’s always worth relying on a service to do it. I’ve been using Algolia, it’s very impressive and incredibly quick to get up and running. Again, something that could take months to build from scratch can be added within 30 minutes. Check out their demos to see how easy it is to get something incredibly powerful. Definitely worth looking in to.

User systems

Generally, I write my user authentication from scratch as I like having the full control over it, but there are good gems out there such as Devise if you want to add a quick user system. With my authentication, I like to use Namecase to properly case customers names and Cancan to add in user roles quickly.

For any kind of social login (e.g. “Log in with Facebook”), I always use Omniauth which is great but for my tastes it’s a little bit overcomplicated. If anyone knows anything simpler, just let me know!

Accepting payments

I’m a big, big Stripe fan — if you need to accept credit cards for one-off payments or subscriptions, look into them. There’s a little bit of Javascript to add as well as Ruby, but it’s very quick to get going. You should definitely use Stripe over Paypal, it’ll be quicker, cheaper and they’re a really nice company too.

If you prefer to accept your payments via Direct Debit, there’s also the great GoCardless which again has some great documentation.

User testing

If you’re a stats nerd (like I am) and you want to add A/B testing on to your site, look into Split which is very easy to implement. The only thing it relies on is Redis — I use the openredis Heroku add-on to use it.

APIs

To do any kind of scraping, such as what I do with the @newsycombinator Twitter bot, I generally use HTTParty and Nokogiri together. I use HTTParty to grab the content from the 3rd party site, then use Nokogiri to turn it into something I can parse.

There are some specific gems out there for particular social networks, for instance, the Twitter gem and Koala for Facebook are good.

For any kind of real time sites, for instance if you’re building a chat site or an online game, look into Pusher.

Notifications

As I like being completely up-to-date with everything, I like getting notifications everywhere. If I need to be alerted to something super important, I like to get notified by SMS so I integrate Twilio with Steve Graham’s unofficial-but-better twilio-ruby.

For other notifications, I like to be notified in team chat rooms. I prefer Slack over Hipchat as the design is better, but they’re both great. Use the slack-notify or hipchat-rb gem to hook your site up!

Emails

When I’m sending out emails, I like to use Sendgrid as it’s super easy to set up and get running. HTML emails are a pain in the arse to build so using the Roadie gem is a great way to solve some of that pain by inlining your stylesheets.

Errors

Every site has errors, there isn’t a developer out there who doesn’t. Even DHH gets bugs. Even if you test your site to death, there will be errors popping up that you didn’t realise you could get. Don’t feel bad about getting them, instead just be notified properly and learn to debug better.

I use Sentry to let me know via email and Slack if there’s errors popping up. Papertrail is also great if you want to search through your logs to find certain events happening.

For development debugging, better_errors is ridiculously good (install it with binding_of_caller). It replaces the usual Rails error page with much more information and also live in-browser debugging too. Again another gem that should be part of the default Rails platform.

Testing

Now of course, we don’t want to have to use the error services and gems above. We still want to make sure our code still works whenever we change things.

I’m a fan of Minitest over RSpec but they’re both good for general automated testing. For writing integration tests (e.g. automating users clicking around your site), look into Capybara — it’s pretty awesome and very useful.

For making test data, I prefer to use Factory Girl over fixtures for its flexibility. To make testing something that you just leave running in the background, look at Guard.

Other useful testing gems include VCR (a way to test with APIs) and Timecop (a way to freeze and fast forward time).

One service I’ve used which I really like is Code Climate which helps you keep the quality of your code very high — the only downside, which is why I stopped using it, is that the price is just far too high for most startups.

Deployment

I admit that I’m a lazy developer. The reason I code is to do things that I can’t be bothered to do manually. This is why I use the amazing Heroku. I don’t want to worry about setting up Linux and running patches in the future, I’d rather pay a little bit more to have other people fixing things behind the scenes. Heroku is by far the easiest platform to get set up on.

I like to set up three different servers to have different environments to test with. They are development (just to try out things), production (the live site) and staging (the same database as production but to try out code before it goes live). To do this I use the heroku_san gem to help me out. All I need to do to deploy to staging is:

rake staging deploy

Easy peasy.

To make sure all the code is super quick, I use New Relic to monitor speeds and spot any slow areas of sites. I also use caching on production using the dalli gem with Memcachier. The Heroku Scheduler add-on is great.


If you’ve never tried Ruby or Rails before, I would definitely recommend looking into it. I used to write PHP, then I moved on to Python with Django but I’ve found Ruby on Rails to be by far the best framework to create sites. This is why I recommend it to clients and students of mine.

The best way to learn Rails is to read the official guides and ignore most of the online learning platforms like Codecademy as they’re not very practical. Have a project that you want to build, have some grit and be determined!


New side project

I have a new project that I’m launching the next few weeks that will let people find and discover new gems called Bundle Update. I’m very excited to get it live and it’s looking great. I want to make it easier to find out what other people use and make it easier for beginners to get started. Sign up and I’ll let you know when it launches.

Show your support

Clapping shows how much you appreciated Rik Lomas’s story.