Back to RoR Development posts

Ruby on Rails: Top 5 Gems to Enhance your Application

May 2023

Creating a Ruby on Rails app can be a challenging task, but it can be made easier by utilizing different gems. These gems consist of third-party code libraries that can significantly speed up the development process. While some of these gems are necessary for Rails, others can still heavily impact the app’s performance and overall development quality.

At Bit Zesty, we specialize in the development and maintenance of Ruby on Rails applications across various sectors and industries. Although our projects vary, they often face similar challenges such as authentication, background processing, performance, and code quality. To overcome these challenges, we use consistent strategies and approaches, relying on tried-and-tested gems that have proven their efficacy over the years. Our selection is based on our valuable experience and expertise.

Devise

Devise is a comprehensive gem that addresses authentication in Ruby on Rails applications. It’s equipped with modules that cater to various aspects of authentication, including user registration, hashed passwords, account confirmation and recovery, and user tracking.

Pros: It’s reliable, open-source, feature-rich, and boasts robust community support. Devise is also customisable, offering helper methods, controllers, and views that you can override or use as default.

Cons: It might be too complex for small projects or beginners to customise.

Why We Recommend Devise: Devise is widely adopted in numerous projects, perfectly compatible with Rails apps, and has stood the test of time.

Alternatives: OmniAuth, Auth0, or custom-built authentication using the “bcrypt” gem and ActiveModel’s has_secure_password.

Sidekiq

Sidekiq is a Ruby framework that excels in background jobs processing. It works by managing background jobs in separate threads of the same process.

Pros: It’s multi-threaded, easy to set up and use, scalable, well-documented, performs well, and offers a web interface and API.

Cons: Heavy dependency on Redis. Thread-safe code is a must.

Why We Recommend Sidekiq: It’s simple to use, works seamlessly with Rails applications, can function as an ActiveJob adapter, and is performance optimised. Its multi-threading feature also allows for efficient resource and power utilisation.

Alternatives: Delayed Job, Resque

SimpleForm is a gem designed to streamline and enhance web form creation. It offers a clear and simple DSL, allowing developers to create intricate forms with varied inputs and labels using Ruby code.

SimpleForm

Simpleform is a flexible form builder, that helps speed up the development of web forms.

Pros: It’s flexible, comprehensive, and easily extendable. SimpleForm also integrates well with Bootstrap and Zurb Foundation.

Cons: It may sometimes generate unexpected HTML output. We don’t recommend it for beginners until they understand how Rails works.

Why We Recommend SimpleForm: For projects that use server-side template rendering via erb, haml, or slim engines, SimpleForm’s set of form-building helpers is invaluable. It accelerates front-end development and ensures consistency across pages and apps.

Alternatives: Native Action View helpers, Formtastic

RuboCop

RuboCop is a Ruby static code analyser and formatter. It primarily adheres to the Ruby Style Guide and can automatically rectify identified issues in the codebase.

Pros: It’s open-source, free, adheres to Ruby style guides, and has auto-correction capabilities.

Cons: Some default settings might not align with your preferences, and some rules may contradict your internal conventions.

Why We Recommend RuboCop: It fosters a clean and consistent codebase. Creating and sharing a config file across your projects helps train engineers and cultivate a cohesive programming style within your team.

Alternatives: Reek, SonarQube, StandardRB

Bullet

Bullet is a performance-oriented gem that identifies performance bottlenecks in your codebase. It evaluates all database queries in the development environment and alerts you when eager loading (N+1 queries) should be added, isn’t necessary, or when a counter cache should be used.

Pros: It’s straightforward to use. Simply add it to the Gemfile and check the “log/bullet.log” file for Bullet gem output.

Cons: A fully-fledged AMP would be better for tracking issues in production, like Appsignal or NewRelic.

Why We Recommend Bullet: It helps us eradicate all N+1 queries and optimise our app in the development environment before deploying changes to production. Moreover, Bullet educates developers on writing optimal code.

Alternatives: Manual inspection of the development.log file and check your database queries.

Here at Bit Zesty, we take great care in selecting the best gems to keep your Ruby on Rails application running smoothly. Our team is dedicated to providing top-notch support and maintenance services to our clients, showing our commitment to excellence and expertise in the field.


Stay up to date with our blog posts

Keep up-to-date with our latest blog posts, news, case studies, and thought leadership.

  • This field is for validation purposes and should be left unchanged.

We’ll never share your information with anyone else. Read our Privacy Policy.