Ruby Gem Guide: how to install and work with local gems.
New to Ruby? This Ruby Gem Guide will show you how to install and work with our favourite local gems.
So, what exactly is a gem?
Shortly: it is a plug-in. An additional functionality added to the main product to fulfil specific needs.
And how to install gem?
Easily. Of course, on top of that you must install Ruby itself, but as you're still reading my words I assume you know what the fuss is all about.
Find the gem that interests you and add it to the Gemfile. Make sure to install the latest stable release:
`gem install GEM_NAME`
Now, install via bundler. The bundler itself is also a gem, so the command will look like this:
`gem install bundler'
Using bundler allows other developers to work on your app with the same version of every gem.
Now you can install gems using this:
'bundle install'
Then, restart the server and apply the changes.
What Ruby Gems do we use?
Below you can find list of Best Ruby Gems for harder, better, faster, stronger web development our devs use from time to time.
Airbrake
gem 'airbrake'
The official Airbrake library for Ruby on Rails. Airbrake combes through your code, tracks bugs, captures errors and aggregates the results for developer review.
Annotate
gem 'annotate', '~> 2.6.6'
Annotates Rails and ActiveRecord models as a gem. Keeps track of your database models and attributes, by adding schema information in your model file.
Awesome_print
gem 'awesome_print'
Great Ruby debugging companion: supports Ruby objects with colored output and visualizes their structure in an easy-to-read way.
Cancancan
gem 'cancancan'
Continuation of CanCan, the authorization Gem for Ruby on Rails. It lets you define permissions for given context. All permissions are stored in a single location.
Carrierwave
gem 'carrierwave'
Very useful gem that helps you to add file uploads to your Ruby application. Integrates image uploads with your model and stores them on different backends. It also allows you to convert video files with streamio-ffmpeg gem 'streamio-ffmpeg'
.
Here you'll find some tips how to convert video files with CarrierWave.
Devise
gem 'devise'
Flexible and popular authentication solution for Rails applications. It prepares all the requirements in the code that are needed to create accounts, login or logout a newly created user.
Dotenv-rails
gem 'dotenv-rails'
A library that makes loading environment much easier. It loads environment-specific settings into environment variables. In Rails applications dotnev automatically loads environment variables from .env
to ENV .
Friendly_id
gem 'friendly_id'
Friendly gem for creating user friendly URLs.
Friendly_id that makes your model ids in your URL readable to human by generating a URL slug.
Haml-rails
gem 'haml-rails'
Gem that looks after the beauty of your code: by eliminating the repetitive tags of HTML and integrating conditional logic Haml-rails makes it easier to read.
Kaminari
gem 'kaminari'
Kaminari provides clear implementation of pagination by using scope called page with Active Record queries.
Lit
gem 'lit'
Rails i18n web interface. Proud to say, Lit is our homemade product, carefully prepared by our developers.
Translate your apps with pleasure (sort of...) and for free. It's simple i18n web interface, build on top of twitter bootstrap, that one may find helpful in translating app by non-technicals.
UPDATE!
Since 2014, when we open sourced Lit on GitHub, it has been downloaded over 26,000 times and still counting. We have also used the gem as a feature of most web apps we have developed over the years. Five years is long enough to gather feedback from our customers and the GitHub community, and spot the areas for improvement. This is how we created the new, better Lit web interface for translating your apps.
Among the very highlights of Lit 1.0 are: automatic cloud translation (using Google Cloud Translate or Yandex), the 'deleted and visited again' tab, enabling you to restore a once-deleted translation key whenever it's called again by the console, the automatic 'translated' status, as well as import from and export of the keys to .csv files.
Read more about how Lit 1.0 can improve your app's i18n process in the new article on our blog.
Nested_form
gem 'nested_form'
This is a Rails gem that manage multiple nested models in a single form. It does so in an unobtrusive way through jQuery or Prototype.
Quiet_assets
gem 'quiet_assets'
Installing Quiet Assets will automatically suppress the log messages and turn off the Rails asset pipeline log.
Ransack
gem 'ransack'
Ransack provides excellent help in building complex search forms. It has some really powerful features available such as sorting or conditional search.
Responders
gem 'responders'
A pack of responders modules to dry up your Rails 4.2+ app. Set contains responders like FlashResponder, HttpCacheResponder, CollectionResponder and LocationResponder.
Sidekiq
gem 'sidekiq'
Sidekiq is a full-featured background processing framework for Ruby. It aims to be simple to integrate with any modern Rails application and much higher performance than other existing solutions.
Simple_form
gem 'simple_form'
Gem that generate forms with many options to customize generated markup. Simply.
Transitions
gem 'transitions'
Transitions is an easy to use library, the state machine extracted from ActiveModel so it requires it's compliance.
Found this one interesting? Don't miss the second part of our best Ruby gems guide!
Know, seen, use, dream of other superb ruby gems worth mentioning? Give us a shot and leave a comment!
Oh, and by the way: have you seen our Free Ruby Tutorial: "Create your own SaaS app in Rails"?
Photo: gratisography.com