[RUBY] [Rails 6] About main gems

Introduction

When using Rails, I used puma, webpacker, and listen as a matter of course, but honestly I didn't really understand what they meant. I would like to summarize the main gems here.

Rails default main gem

Below is the default gem generated by Rails 6.

Gemfile


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
```

 I will explain each of them.

sqlite3
 A C language library that implements the SQL database engine.
 Since there is no security function such as no password setting, it is basically used in the development environment and test environment, and another database engine is used in the production environment.

https://www.sqlite.org/index.html

puma
 Used to build an HTTP 1.1 server for Ruby web applications. Use the thread pool to handle requests.

https://puma.io/
https://github.com/puma/puma

sass-rails
 You can use Sass (SCSS) with Rails.

https://github.com/rails/sass-rails

webpacker
 A webpack wrapper that implements major settings commonly used in web applications as standard. webpack is a static module bundler for the latest JavaScript applications [^ 1].

 [Main functions]
 ・ [Webpack 4.x.x](https://webpack.js.org/)
 -Automatic code split using multiple entry points [^ 2]
 · Convert new JavaScript syntax (ES6) to work in the browser
 ・ Abundant achievements in modern frameworks such as React, Vue.js, PostCSS, etc.

https://github.com/rails/webpacker

Jbuilder
 Jbuilder provides a simple DSL (Domain Specific Language) for declaring JSON structure.
https://github.com/rails/jbuilder

turbolinks
 Faster link tracking in web applications.
https://github.com/turbolinks/turbolinks-classic

bootsnap
 It shortens the startup time by optimizing the processing at the time of rails startup (cache the path and ruby compilation result).
 It also supports ActiveSupport and YAML.

https://github.com/Shopify/bootsnap/blob/master/README.jp.md

byebug
 Debugging tool.

https://github.com/deivid-rodriguez/byebug

web-console
 A library for debugging that allows you to launch the console in View and see the status of variables and parameters. It becomes easier to debug the error part.

https://github.com/rails/web-console

listen
 It can detect changes in files and use them as hooks for some processing.

 [Main functions]
 · Detects file changes, additions and deletions
 -Monitor multiple directories

https://github.com/guard/listen

spring
 Rails application preloader [^ 3]. It speeds up development by keeping your application running in the background, eliminating the need to launch your application every time you run a test or migration.

https://github.com/rails/spring

spring-watcher-listen
 Instead of polling the filesystem [^ 4], Spring uses Listen to monitor filesystem changes.

https://github.com/jonleighton/spring-watcher-listen/

capybara
 Helps test web applications by simulating how real users interact with the app.

https://github.com/teamcapybara/capybara
https://en.wikipedia.org/wiki/Capybara_(software)

selenium-webdriver
 Since capybara does not support JavaScript, simulate it with selenium-webdriver.

https://github.com/SeleniumHQ/selenium/tree/trunk/rb

webdrivers
 It is intended to enable the web browser to be operated and information to be obtained from external software.

https://github.com/titusfortner/webdrivers

tzinfo-data
 Used for time zone information on Windows. On Unix-based operating systems, you don't need to use tzinfo as you can access the system timezone information directly.

https://github.com/tzinfo/tzinfo-data

# Other major gems

bcrypt
 Password can be encrypted.

https://github.com/codahale/bcrypt-ruby

devise
 You can create a user authentication function that is essential for Web applications. You can also create a membership registration form and implement authentication via email, Facebook, etc.

https://github.com/heartcombo/devise

kaminari
 You can easily add pagination functionality.

https://github.com/kaminari/kaminari

carrierwave

 Image upload function.

https://github.com/carrierwaveuploader/carrierwave

active admin
 You can create CRUD management screens.

https://github.com/activeadmin/activeadmin

ruboCop
 A static code analysis tool that checks if it is written according to coding standards.

https://github.com/rubocop-hq/rubocop

pry-rails
 Like Ruby's irb, you will be able to use methods etc. in the rails console.

https://github.com/rweng/pry-rails

faker
 Generate fake data.

https://github.com/faker-ruby/faker

capistrano
 Automatic deployment tool.

https://github.com/capistrano/capistrano

# Summary
 Rails has a long history, so there are many Gem. If you are a beginner, it will be difficult to select. First of all, it seems necessary to select Gem by picking up what kind of function is required and how much before development. I will put up a site that seems to be a reference for selecting Gem. I will update this article more and more if there is a useful Gem.
 [Gem Search Tool](https://www.ruby-toolbox.com/)
 [Gem Ranking Site](https://bestgems.org/)

 [^ 1]: A tool that resolves the dependencies of JavaScript files that are divided into modules and are separated into one file.
 [^ 2]: The place where the program starts executing. ([Entry Point-Wiki](https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%B3%E3%83%88%E3%83%AA%E3%83%BC % E3% 83% 9D% E3% 82% A4% E3% 83% B3% E3% 83% 88 #: ~: text =% E3% 82% A8% E3% 83% B3% E3% 83% 88% E3 % 83% AA% E3% 83% BC% E3% 83% 9D% E3% 82% A4% E3% 83% B3% E3% 83% 88% E3% 81% A8% E3% 81% AF% E3% 80 % 81% E3% 83% 97% E3% 83% AD% E3% 82% B0% E3% 83% A9% E3% 83% A0,% E3% 81% 8C% E3% 83% A1% E3% 82% A4% E3% 83% B3% E3% 83% AB% E3% 83% BC% E3% 83% 81% E3% 83% B3% E3% 81% A7% E3% 81% 82% E3% 82% 8B% E3% 80% 82)))
 [^ 3]: Pre-read images and contents and cache them before displaying the site. (Reference → [What is a preloader](https://www.ikesai.com/words/%E3%83%97%E3%83%AA%E3%83%AD%E3%83%BC%E3%83] % 80% E3% 83% BC))
 [^ 4]: Mainly to avoid conflicts such as communication, the host side periodically makes inquiries to each device, and when the conditions are met, transmission / reception and various processing are performed. ([Polling-wiki](https://ja.wikipedia.org/wiki/%E3%83%9D%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0_( % E6% 83% 85% E5% A0% B1) #: ~: text =% E3% 83% 9D% E3% 83% BC% E3% 83% AA% E3% 83% B3% E3% 82% B0% EF% BC% 88 polling% EF% BC% 89% E3% 81% A8% E3% 81% AF% E3% 80% 81,% E6% 96% B9% E5% BC% 8F% E3% 81% AE% E3 % 81% 93% E3% 81% A8% E3% 81% A7% E3% 81% 82% E3% 82% 8B% E3% 80% 82))


Recommended Posts

[Rails 6] About main gems
About Rails 6
About Rails routing
[Rails] About ActiveJob ,!
About Rails controller
About RSpec (Rails)
[Rails] About migration files
[Rails] About active hash
About rails application server
About rails kaminari pagination
About rails version specification
MEMO about Rails 6 series
[Rails] About Slim notation
[rails] About devise defaults
Rails: About partial templates
About rails strong parameters
[Beginner] About Rails Session
about the where method (rails)
[Ruby on Rails] about has_secure_password
About naming Rails model methods
[Rails] About scss folder structure
[Rails] About Rspec response test
About Rails scraping method Mechanize
[Rails] About the Punk List function
Learn more about gems and bundlers
About the symbol <%%> in Rails erb
[Rails] About implementation of like function
[Rails] About helper method form_with [Basic]
About =
About RSpec introduction & closely related gems
Consideration about Rails and Clean Architecture
[Ruby on Rails] 1 model CRUD (Routing Main)
[Ruby on Rails] About bundler (for beginners)
[Rails 6.0] About batch saving of multiple records
[Ruby on Rails] About Active Record callbacks
[Rails] About local: true described in form_with
Rails: A little summary about data types