Find out what Ruby on Rails Gems will help your app stand out from rest. This list of must have 2015 Ruby on Rails Gems gives your app the edge.
Say goodbye to the Red Screen of Death. Better Errors does exactly as the title infers – it takes you away from that gut-punching red screen and brings you to a much nicer looking, and more informative display of any screw-ups we make.
Red Screen of Death
Prettier Screen of Death
Image Source: http://ershadk.com/blog/2013/07/21/grandham-week-5/
When checking how my tables are interacting with one another in development – I tend to use the Rails Console to make sure everything is ship-shape.
The output of information in the Rails Console can be difficult to digest so that leaves us with a need to smarten up the output. Awesome print solves this very problem.
Go to the Rails Console (type: rails c in your terminal window) enter User.last (or whichever model you created) in the rails console.
From the screenshot above, you can see that the output in the Rails Console is fairly hard to read.
Awesome Print takes this output it and effectively styles it to make it more legible.
To install Awesome Print, we add the following to our Gemfile.
# Gemfile gem “awesome_print”, require:”ap”
We now run Bundle Install
Back in the rails console we run the same command (User.last or whatever you used), but we now add ap to the start of the commend. Your command is now ap User.last.
This passes the ap method on to your command and renders your output like the screenshot below
Like Rails but hate debugging? Well I’ve got a great Gem for you!! Enough of the bad sales-pitch. The Pry Rails Gem can save you tons of debugging time by allowing you to view what information is being passed into your objects for one.
Install Pry by opening your Gemfile and inputting gem “pry-rails”, group:”development”.
Time to Bundle Install
Temporarily add binding.pry in any controller then point your browser to that controller by visiting that page in your app.
Sticking with our User model from the Awesome Print example:
Class SessionsController def my_action @user = User.first binding.pry endend
All the necessary info for Pry will be output in your terminal window. Pry stops the execution where you placed that binding.pry and now displays any variables and values being called by your app.
Newrelic.com have a Rails Gem and it can be used with a Free new Relic account. This gives you access to their local development features.
New Relic is a software metrics and performance reporting suite that can give developers key insights into how they can optimize application performance. You can view a great tutorial on setting up New Relic from TutsPlus.
All you have to do is:
# Place this at the bottom of the Gemfile # as recommened by Newrelic docs gem ‘newrelic_rpm’
You will need to sign-up for a New Relic account. You can claim a free account by going to Newrelic.com. Once you are signed up you can get the Newrelic.yml file; drop Newrelic.yml into your config folder of your rails application.
I’ve only touched onto New Relic recently so to a large degree I’m still finding my feet. Developer mode takes a bit of getting used to so I advise checking the official documentation and watching some youtube video on New Relic for further information.
If you stick with it, you can get some very useful data about your app and its performance. Just append /newrelic to your URL.
CarrierWave is an extremely useful Gem which I’ve used numerous times when file upload and download were a requirement. CarrierWave is straightforward to implement and has a nicely detailed Git repo to get you started.
factory_girl provides a framework and DSL for defining and using factories – less error-prone, more explicit, and all-around easier to work with than fixtures. It has straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
Active Merchant is an extraction from the e-commerce system Shopify. Shopify’s requirements for a simple and unified API to access dozens of different payment gateways with very different internal APIs was the chief principle in designing the library. It was developed for usage in Ruby on Rails web applications and integrates seamlessly as a plugin but it also works excellently as a stand alone library.