13 Essential Gems Used in Rails
Introduction
Today we will introduce more about Gem and show you 13 Gems that you probably would frequently use in Rails, from essential to minor.
What is Gem?
A gem is a package written in Ruby. A package is a computer program with a specific functionality that can be called from other programs and stored in a single file.
Generally, a package management system called bundler is used to manage gems. Bundler corresponds to npm in Node.js.
Using packages eliminates the need to implement necessary functions from scratch, greatly improving development efficiency.
Many gem packages are managed by RubyGems. You can search for gems at the following sites:
Moreover, you can also publish your DIY gem.
Frequently Used Gems
rspec-rails
rspec-rails
is a gem that introduces a testing framework called RSpec to Ruby on Rails.
Using RSpec, you can run tests by executing commands. It is easy to use because tests can be run on a class or method basis.
factory_bot_rails
factory_bot_rails
is a gem that provides methods to easily create sample test data.
For this reason, it is often used in combination with rspec-rails
.
rubocop
rubocop
is a Ruby static code analysis gem.
By running it, you can check your Ruby code, and it will format the code and issue warnings.
For example, if you forget to leave indentation, it will warn you like this at runtime.
pry-rails
pry-rails
is a debugging tool used for Rails.
It allows you to suspend processing at a line of code with binding.pry
and perform the same operations on that line as on the console.
activeadmin
activeadmin
is a gem that can be used to easily create administrative screens.
By using activeadmin
, you can create CRUD (Create, Read, Update, Destroy) screens for your models very easily.
With the default configuration, you can create a screen like this.
cancancan
cancancan
is a gem that manages permissions.
It allows you to restrict access to specific users and set permissions for each screen.
devise
devise
is a gem that allows you to add authentication features such as account registration, login, and logout.
This makes it easy to implement secure authentication. Password change and email authentication are also available.
annotate
annotate
is a gem that writes model information to a file as comments. It is very useful to know at a glance what columns are used in a model.
bullet
bullet
monitors queries during application development and notifies you when N+1 problems occur.
The N+1 problem is a problem in which extra queries are issued in the loop process, resulting in poor performance.
By eliminating this problem and reducing the number of queries the application performs, application performance can be improved.
rails-i18n
rails-i18n
allows you to internationalize your web application by placing translation files in the locale file.
dotenv-rails
Environment variables can be handled by installing dotenv-rails
.
You can prepare an .env
file in the root directory of your project and define variables in it, which will be loaded automatically.
kaminari
kaminari
is a gem that makes it easy to implement pagination functionality.
whenever
whenever
is a gem that manages crontab.
By creating a cron with whenever
, you can run jobs such as rake task periodically.
Summary
We have introduced 13 essential gems for Rails in this blog.
All of them are gems that are often used in web application development, so please try them out.
About Us💡
GROWI
In addition, I want to introduce a little more about GROWI, an open software developed by us WESEEK, Inc.
GROWI is a wiki service with features-rich support for efficient information storage within the company. It also boasts high security and various authentication methods are available to simplify authentication management, including LDAP/OAuth/SAML.
GROWI originated in Japan and GROWI OSS is FREE for anyone to download and use in English. For more information, go to GROWI.org to learn more about us.
GROWI.cloud
GROWI.cloud is the online version of GROWI that allows non-engineers to manage knowledge easily without system-building processes.
Besides organizational use, GROWI.cloud is also available for individual use and you can always start with a free trial here. After the one-month free trial, you can change your plan into either the individual, duo, or trio plan, OR continue to use the personal plan for FREE with a maximum of 25 users! Go to price & features to learn about the details.
GROWI.cloud origins in Japan and now also offered in the Philippine and other countries which allows customers to use the service in English.
Go to GROWI.cloud to learn more about us. You can also follow our Facebook to see updates about our service.