This website uses cookies to better the user experience of its visitors. Where applicable, this website uses a cookie control system, allowing users to allow or disallow the use of cookies on their computer/device on their first visit to the website. This complies with recent legislative requirements for websites to obtain explicit consent from users before leaving behind or reading files such as cookies on a user’s computer/device. To learn more click Cookie Policy.

Privacy preference center

Cookies are small files saved to a user’s computer/device hard drive that track, save, and store information about the user’s interactions and website use. They allow a website, through its server, to provide users with a tailored experience within the site. Users are advised to take necessary steps within their web browser security settings to block all cookies from this website and its external serving vendors if they wish to deny the use and saving of cookies from this website to their computer’s/device’s hard drive. To learn more click Cookie Policy.

Manage consent preferences

These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
Cookies list
Name _rg_session
Provider rubygarage.org
Retention period 2 days
Type First party
Category Necessary
Description The website session cookie is set by the server to maintain the user's session state across different pages of the website. This cookie is essential for functionalities such as login persistence, ensuring a seamless and consistent user experience. The session cookie does not store personal data and is typically deleted when the browser is closed, enhancing privacy and security.
Name m
Provider m.stripe.com
Retention period 1 year 1 month
Type Third party
Category Necessary
Description The m cookie is set by Stripe and is used to help assess the risk associated with attempted transactions on the website. This cookie plays a critical role in fraud detection by identifying and analyzing patterns of behavior to distinguish between legitimate users and potentially fraudulent activity. It enhances the security of online transactions, ensuring that only authorized payments are processed while minimizing the risk of fraud.
Name __cf_bm
Provider .pipedrive.com
Retention period 1 hour
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to support Cloudflare Bot Management. This cookie helps to identify and filter requests from bots, enhancing the security and performance of the website. By distinguishing between legitimate users and automated traffic, it ensures that the site remains protected from malicious bots and potential attacks. This functionality is crucial for maintaining the integrity and reliability of the site's operations.
Name _GRECAPTCHA
Provider .recaptcha.net
Retention period 6 months
Type Third party
Category Necessary
Description The _GRECAPTCHA cookie is set by Google reCAPTCHA to ensure that interactions with the website are from legitimate human users and not automated bots. This cookie helps protect forms, login pages, and other interactive elements from spam and abuse by analyzing user behavior. It is essential for the proper functioning of reCAPTCHA, providing a critical layer of security to maintain the integrity and reliability of the site's interactive features.
Name __cf_bm
Provider .calendly.com
Retention period 30 minutes
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to distinguish between humans and bots. This cookie is beneficial for the website as it helps in making valid reports on the use of the website. By identifying and managing automated traffic, it ensures that analytics and performance metrics accurately reflect human user interactions, thereby enhancing site security and performance.
Name __cfruid
Provider .calendly.com
Retention period During session
Type Third party
Category Necessary
Description The __cfruid cookie is associated with websites using Cloudflare services. This cookie is used to identify trusted web traffic and enhance security. It helps Cloudflare manage and filter legitimate traffic from potentially harmful requests, thereby protecting the website from malicious activities such as DDoS attacks and ensuring reliable performance for genuine users.
Name OptanonConsent
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonConsent cookie determines whether the visitor has accepted the cookie consent box, ensuring that the consent box will not be presented again upon re-entry to the site. This cookie helps maintain the user's consent preferences and compliance with privacy regulations by storing information about the categories of cookies the user has consented to and preventing unnecessary repetition of consent requests.
Name OptanonAlertBoxClosed
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonAlertBoxClosed cookie is set after visitors have seen a cookie information notice and, in some cases, only when they actively close the notice. It ensures that the cookie consent message is not shown again to the user, enhancing the user experience by preventing repetitive notifications. This cookie helps manage user preferences and ensures compliance with privacy regulations by recording when the notice has been acknowledged.
Name referrer_user_id
Provider .calendly.com
Retention period 14 days
Type Third party
Category Necessary
Description The referrer_user_id cookie is set by Calendly to support the booking functionality on the website. This cookie helps track the source of referrals to the booking page, enabling Calendly to attribute bookings accurately and enhance the user experience by streamlining the scheduling process. It assists in managing user sessions and preferences during the booking workflow, ensuring efficient and reliable operation.
Name _calendly_session
Provider .calendly.com
Retention period 21 days
Type Third party
Category Necessary
Description The _calendly_session cookie is set by Calendly, a meeting scheduling tool, to enable the meeting scheduler to function within the website. This cookie facilitates the scheduling process by maintaining session information, allowing visitors to book meetings and add events to their calendars seamlessly. It ensures that the scheduling workflow operates smoothly, providing a consistent and reliable user experience.
Name _gat_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _gat_UA-* cookie is a pattern type cookie set by Google Analytics, where the pattern element in the name contains the unique identity number of the Google Analytics account or website it relates to. This cookie is a variation of the _gat cookie and is used to throttle the request rate, limiting the amount of data collected by Google Analytics on high traffic websites. It helps manage the volume of data recorded, ensuring efficient performance and accurate analytics reporting.
Name _ga
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga cookie is set by Google Analytics to calculate visitor, session, and campaign data for the site's analytics reports. It helps track how users interact with the website, providing insights into site usage and performance.
Name _ga_*
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga_* cookie is set by Google Analytics to store and count page views on the website. This cookie helps track the number of visits and interactions with the website, providing valuable data for performance and user behavior analysis. It belongs to the analytics category and plays a crucial role in generating detailed usage reports for site optimization.
Name _gid
Provider rubygarage.org
Retention period 1 day
Type First party
Category Analytics
Description The _gid cookie is set by Google Analytics to store information about how visitors use a website and to create an analytics report on the website's performance. This cookie collects data on visitor behavior, including pages visited, duration of the visit, and interactions with the website, helping site owners understand and improve user experience. It is part of the analytics category and typically expires after 24 hours.
Name _dc_gtm_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _dc_gtm_UA-* cookie is set by Google Analytics to help load the Google Analytics script tag via Google Tag Manager. This cookie facilitates the efficient loading of analytics tools, ensuring that data on user behavior and website performance is accurately collected and reported. It is categorized under analytics and assists in the seamless integration and functioning of Google Analytics on the website.

53 Best Ruby Gems We Use at RubyGarage

  • 138071 views
  • 16 min
  • Feb 26, 2021
Kirill S.

Kirill S.

Ruby/JS Developer

Bohdan Ch.

Bohdan Ch.

Ruby/JS Developer

 Volodymyr O.

Volodymyr O.

Ruby/JS Developer

Ihor S.

Ihor S.

JavaScript/HTML/CSS Developer

Maryna Z.

Maryna Z.

Copywriter

Vlad V.

Vlad V.

Chief Executive Officer

Share

Here at RubyGarage we work closely with Ruby and Ruby on Rails technologies. We like Ruby for its resourcefulness and vibrant community, while Ruby on Rails is appreciated for its multiple ready-made solutions that allow for rapid software development.

Such rapidity is mainly achieved through using Ruby gems – libraries with specific functionalities that allow us to extend and customize our apps. In Ruby on Rails, there are gems for every purpose: from authentication and authorization, to payments processing and testing.

Check out our Ruby gems list that features the best libraries we regularly use in our projects – and recommend. Enjoy!

Active Record

Active Record is the default ORM for Ruby on Rails. Though it offers rich functionality, some projects require custom solutions or additional features. We’ve picked out a few gems that extend Active Record’s functionality making it more powerful, flexible, and versatile.

Pagination – Try the pagy gem that is very modular, completely agnostic, and does not load any unnecessary code in your app. Its updated version is faster, lighter, simpler, and more efficient than other pagination gems.

Clone – If you need to create a copy of an Active Record object and its associations, check out the clowne. This is a flexible and easy-to-use tool that provides the ability to connect various ORM adapters.

Soft delete – To add conventions for flagging records as discarded, try discard, a simple ActiveRecord mixin. It doesn't override any ActiveRecord methods and provides convenience methods and scopes for hiding, restoring, and querying records.

Finite state machines – AASM, which replaces the acts_as_state_machine plugin, works with any Ruby object, including ActiveRecord. AASM adds finite state machines (sets of rules that dictate what an application or a device should do) to Ruby classes.

Versioning – For logging DB records changes, try logidze. The gem allows you to create a DB-level log, providing you with an API to browse this log. The log is stored with the record itself in JSONB column. No additional tables are required.

Internationalization – When translating your application into foreign languages, globalize, powered by I18n API, comes in handy. Globalize adds translations of your website’s content to ActiveRecord models, which is especially useful when you deal with the translation of non-static database content.

Encryption – To ensure security, we choose lockbox that provides modern encryption for Ruby and Rails. We like it because it has zero dependencies, many integrations, and makes migrating existing data easy. This gem works with database fields, files, and strings, maximizing compatibility with existing code and libraries. 

Testing

If you’re going to write automated tests for your applications (which is integral to building RoR apps), there are several awesome Ruby gems that will come in handy. While working on our projects, we use RSpec, factory_bot, Capybara, shoulda-matchers, database_cleaner and simplecov to save time and effort.

We use RSpec – a framework mainly used in BDD and TDD environments – to create tests. Its syntax is neat and descriptive, which allows us to write tests (or specs) as closely as possible to “human” language. We also like RSpec because it’s an effective tool for testing the behavior of a model or a library.

Database_cleaner is often used with RSpec for cleaning up databases during tests. Database_cleaner provides you with the flexibility to configure when your database will be cleaned up: before tests are launched or both before and after each test. And if you face the problem of external requests during tests, you might want to find a solution like the VCR gem, which snatches all external requests with responses and records them to a file so you can “replay” them during testing.

In order to create test data, we use factory_bot. This is a gem with a straightforward definition syntax, support for multiple build strategies, and multiple factories for the same class.

We also use capybara, an acceptance testing library, which effectively automates a user’s interactions in a browser. With Capybara, we’re able to test clickthroughs, form completion (data entry fields, dropdown boxes, checkboxes), availability of items on a page, and more. Bundled with Poltergeist, a popular PhantomJS driver, Capybara provides us with the ability to run testing scenarios in a WebKit from the console.

For generating fake data such as names, addresses, and phone numbers, faker libraries can \help. Another useful gem is site_prism - a page Object Model DSL for Capybara. It gives you a simple, clean, and semantic DSL for describing your site. 

Another gem, shoulda-matchers, lets us easily test typical Rails functionality such as validations and associations by writing compact one-line tests compatible with RSpec. In other words, shoulda-matchers offers matchers that help developers to test basic Rails functionality quickly and easily.

Lastly, the simplecov gem allows us to see the percentage of code covered by unit tests. This gem helps us to track how much code we’ve tested and strive for better results (though achieving 100% coverage is quite challenging).

Coding Style

Coding style is important. In order to write quality code, skillful Rubyists follow the best practices found in The Ruby Style Guide. But why do developers care so much about style? According to the Ruby Style Guide, well-written Ruby reads like a natural language and can be understood even by non-developers. Moreover, well-written code is easy to maintain, modify, and scale.

To assure code quality, developers apply gems that analyze their code and suggest improvements. Let’s see which gems our RubyGarage team prefers.

The rails_best_practices gem is a static code metric tool that analyzes code to find code smells: pieces of code that aren’t technically bugs but that may lead to software issues in the future. Rails_best_practices offers suggestions to improve your code – for example, suggesting the removal of tabs, annotation of models, or additional database indexes. You can share the analysis results with your collaborators and track your results over time to see how your code has improved.

Another code analyzer – with the menacing name RuboCop – assures that your code conforms to the Ruby Style Guide. Style guide freaks and geeks adore RuboCop since it leaves no chance for style violations – they’re reported right in the command line. Some developers find this pretty annoying, but you can configure RuboCop to show only the refactoring suggestions you want. The great thing about RuboCop is that it automatically fixes issues like line breaks, syntax, and the amount of gaps.

We also use lefthook to automatically support our clean code writing. This is a fast and powerful Git hooks manager for any type of projects. It features parallel execution, flexible list of files, gGlob, regexp filters and optional output. 

Debugging

Errors happen all the time when you’re writing code. Whether you make a typo or a gem doesn’t integrate properly, you get unpleasant results. To eliminate these issues, there are a few handy tools we use for debugging errors in Ruby code.

Pry-byebug is another tool we use, and it actually extends the functionality of the Pry and Byebug gems. With pry-byebug, you’re able to implement step-by-step code debugging by setting breakpoints. Pry-byebug allows you to set console (IRB or Rails console) break points so you can check how a piece of code is executed at a certain point.

Last but not least, we must mention the Letter Opener gem, which allows you to preview emails sent from an application straight in your browser’s tab. This is quite useful for applications that send emails (for example, notifications) to multiple users or in cases when you require a quick email preview. With Letter Opener, you don’t have to wait for an email to be delivered to your mailbox but you can quickly preview emails in your browser and make changes if necessary.

Authentication and Authorization

Whether you’re building a social network, an ecommerce solution, or nearly any other kind of application, you generally need to offer login functionality, which means you need to provide authentication and authorization. Some developers prefer to write their own user authentication and authorization solutions, but others use popular ready-to-go Ruby gems that save a whole bunch of time and effort.

It’s hard to find a Ruby developer who hasn’t heard about the Devise gem. It is a flexible authentication solution for Rails based on Warden that should be used together with activeadmin or for monolithic applications. This monstrous gem, based on the Rails MVC stack, adds OmniAuth support to verify users, resetting passwords, if necessary, and storing passwords in the database to simplify authentication. Moreover, Devise tracks metrics including IP addresses and timestamps, expires user sessions after a specified period of time, and locks accounts in case of multiple failed login attempts. Devise can do even more for you – check their GitHub page for more details.

Logging into websites using social accounts such as Facebook or LinkedIn is a regular practice that saves users’ time and nerves. As a rule, social logins in Rails applications are powered by the OmniAuth gem, which creates authentication providers (for social networks including Facebook, Google, and even GitHub), which are integrated into a Rails application. Easy as a pie!

If you need a flexible tool to build an authorization layer for your application, try action_policy. Being composable and extensible, it outperforms older solutions with similar functionality, such as Pundit and CanCanCan. 

Another helpful library is Rolify, which allows you to establish and manage user roles – definitions of what users can do while using an application. For example, when building a marketplace like Airbnb, you’ll probably define two user roles: hosts, who provide their apartments for rent, and users, who rent apartments and receive a completely different set of functions. Rolify is also easily integrated with CanCanCan and Devise to extend their capabilities of user management.

Finally, for providing configurable, manageable, and safe stateful sessions based on JSON Web Tokens, try jwt_sessions. It is designed to be framework agnostic yet easily integrable, and Rails integration is available out of the box.

APIs

In a nutshell, APIs are sets of requirements for exchanging data between applications. You can log in to online stores with your Facebook account thanks to APIs or look for nearby restaurants on Foursquare via Google Maps – also thanks to APIs. Building APIs can sometimes be challenging, but in other cases only requires a few lines of code.

Thanks to many existing Ruby gems for APIs, you don’t have to reinvent the wheel. One great time saver is a gem called jsonapi-serializer - a fast JSON:API serializer for Ruby. It declares syntax similar to active model serializer and features optimized serialization of compound documents. You can also benefit from dox to automate the documentation writing process. This gem generates API documentation from Rspec controller/request specs in a Rails application.

Security

When developing applications that store users’ personal information or financial details, it’s important to ensure data security.

Brakeman is a static security scanner that identifies vulnerabilities in Rails applications. While it may report vulnerabilities even if there aren’t any (since it’s static), you can easily configure a list of warnings in order not to receive unnecessary notifications. If you need to block abusive requests, try rack-attack

In case you want to check your application’s gems for vulnerabilities, take a look at bundler-audit, which runs on top of Bundler. With bundler-audit you can sleep tight and save plenty of time not checking every single gem in your Rails application since the bundler-audit reviews your gemfile.lock for vulnerable gem versions and prevents unreliable gem fetching.

The gem which takes care of applying security-related HTTP headers to Rails application’s responses is Secure Headers. Secure Headers allows you to apply headers like CSP to prevent cross-site scripting and mixed-content attacks and XFO to prevent your content from potential clickjacking attacks.

Payments

If you build an ecommerce solution, you’ll definitely need to provide fast, secure, and convenient payment options.

Active Merchant is a library from the creators of Shopify that provides a centralized API to integrate with many popular payment gateways. This open-source library is well maintained by the Shopify team and currently supports 145 payment gateways available all around the globe.

At RubyGarage, we prefer to work with popular gateways like PayPal, Stripe, and Braintree. But even though Active Merchant handles Stripe and Braintree integration, we often use Braintree Ruby, stripe-ruby, and stripe_event in order to provide lightweight solutions for our applications. Since Active Merchant is a large library, which might slow down an application’s performance, it’s more effective to integrate several payment gateways and not to overload the app.

Uploading Files

Quite often we build web applications that allow users to upload files of various kinds: documents, images, audio, and video. shrinerb/shrine: is a useful toolkit for handling file uploads in Ruby. It’s memory friendly, has a modular design and flexible processing. 

When it comes to images, one of the most effective solutions available is image_processing. It provides higher-level helpers that are commonly needed when handling image uploads.

Scheduled and Recurring Jobs

Background jobs in Ruby applications are processed outside the normal request/response flow and are literally operations in a queue, executed one after another. Processing background jobs is critical for an application’s performance. To provide you with a vivid example, let’s imagine we build an application that sends an email to a user after they sign up. Obviously, an email should be delivered as fast as possible: we all hate to wait two or three seconds expecting a message to pop up in our mailbox. To speed things up, we need to leverage background jobs for operations like sending emails, importing data, calling third-party APIs, and resizing images.

For scheduled jobs the RubyGarage team employs the Sidekiq Redis-supported library that uses Redis as a job management store. This gem impresses developers with its multi-threading capabilities, resulting in impressive speed. Other benefits include convenient monitoring of job processing status the opportunity to execute jobs in parallel. 

There’s also an add-on for Sidekiqsidekiq-cron. It checks for new jobs to schedule every 30 seconds and doesn't schedule the same job multiple times when more than one Sidekiq worker is running. This gem allows you to set up any kind of jobs, like sending congratulation messages to your app users on New Year’s Eve and other holidays. 

Search

Most web applications require a built-in search functionality. To power your application with a search, you might want to take a look at a few helpful gems.

Elasticsearch is a popular search engine for enterprises. By leveraging Elasticsearch, you’re able to implement search on a website, index catalogs of goods (if you’re running an ecommerce store), enable automatic insertion of data, develop a solution for price notifications by indexing prices, implement reverse search, store transactions and actions, and analyze and retrieve data to get comprehensive statistics. We use the Elasticsearch gem for Ruby integrations in Rails applications.

“Awesome,” “great,” “amazing” – these are the words our developers use to describe the Ransack gem. Ransack is appreciated by Ruby developers because it helps them create smart and simple, yet advanced, search forms. Unfortunately, the gem currently isn’t maintained on GitHub, but it doesn’t prevent it from being popular.

Finally, to enable full-text search in a PostgreSQL database, we use the PgSearch gem.

Environment Variables

Storing application configurations in environment variables is a widely used practice derived from the principle of a twelve-factor application; by doing so, you’re able to keep sensitive data like passwords or API keys outside the code repository, but the data is still available during execution. The library that might be helpful in this case is anyway_config. It allows abstractize the configuration layer by introducing configuration classes that describe available parameters and their defaults. 

Admin Panel 

Being a website owner or administrator, you need a dashboard where you’re able to manage your website. In the Ruby world, the most common admin panel tool is Active Admin. It provides its users with out-of-the-box features, including data export to CSV, JSON, and XML, custom search and filtering by types, as well as custom authentication and authorization to differentiate user roles. Active Admin requires manual modifications and customization since it has its own view/controller pattern.

View Helper

Recently, the trend has been towards keeping models, views, and controllers as skinny as possible. So how can we keep everything skinny? View Helpers are modules that contain methods to help you write DRY (Don’t Repeat Yourself), clean, and maintainable code. Let’s look at a few gems that save a whole bunch of time for our developers here at RubyGarage.

In Rails, we have objects everywhere. Draper is a gem-decorator that adds an object-oriented presentation to your web application. If you find the logic in your templates and helpers overly complex, then this gem might be what you need – Draper helps you clean things up with a more object-oriented approach by adding, replacing, or extending an object’s behavior.

Simple Form is a gem that does what its name suggests: it helps you create forms for your Rails applications. In a nutshell, Simple Form helps developers write more elegant code, as well as quicky create dropdown lists, and offers amazing flexibility when working with checkboxes and radio buttons. It can even help you internationalize form elements.

Another useful gem is MetaTags, which helps you create SEO-friendly Rails applications by adding View Helpers for meta tags. MetaTags makes SEO management efficient by giving a more straightforward way to create meta tags while sticking to SEO best practices.

Finally, when developing an ecommerce solution, we need to consider money and currency conversions. The Money-Rails gem solves these tasks in your Rails application by integrating with the Money gem. The Money-Rails gem offers a number of benefits over the Money gem, such as a money class, monetary values, and currency conversion. Moreover, you’re able to create fancy money entry fields which are automatically split into hundreds and thousands with decimal points.

Conclusion

It’s a standard practice to use Ruby gems when working with Ruby on Rails applications. Popular gems solve common problems in Rails applications, including file uploads, authentication, authorization, and testing. Ruby gems also eliminate the need to reinvent the wheel and build your own solutions for each unique app. That said, gems aren’t the silver bullet for all your problems. Gems are more like frozen food from the store; they’re mostly ready to go, but you can’t eat them straight out of the box. Use gems frequently, but remember about serving them right!



CONTENTS

Authors:

Kirill S.

Kirill S.

Ruby/JS Developer

Bohdan Ch.

Bohdan Ch.

Ruby/JS Developer

 Volodymyr O.

Volodymyr O.

Ruby/JS Developer

Ihor S.

Ihor S.

JavaScript/HTML/CSS Developer

Maryna Z.

Maryna Z.

Copywriter

Vlad V.

Vlad V.

Chief Executive Officer

Rate this article!

Nay
So-so
Not bad
Good
Wow
32 rating, average 4.69 out of 5

Share article with

Comments (0)

There are no comments yet

Leave a comment

Subscribe via email and know it all first!