RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

53 Best Ruby Gems We Use at RubyGarage

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.

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!

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! https://rubygarage.org/blog/best-ruby-gems-we-use

Comments

I am sure that reading https://onlineessaywritingservice.review/reviews/freeessaywriter-review can clarify everything about freeessaywriter. It’s important for students to know for sure where they place their orders.

Stunning site! Do you have any helpful clues for trying essayists? I’m wanting to begin my own site soon yet I’m somewhat lost on everything. Would you prompt beginning with a free stage like or go for a paid alternative? There are so many alternatives https://www.assignmentuk.co.uk/write-my-assignment out there that I’m totally overpowered .. Any thoughts? Welcome it!

Thanks for sharing this. I really like your article and of course information you shared. I wanted to learn more about Power BI course.

Thanks

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in