0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gemとは

Posted at

gem

一言で言えばGemfileに必要な機能を記述すれば使える機能のことです。
例えばgemでpry-railsというのがあります。pry-railsはrails cコマンドでコンソールを立ち上げたとき、irbでなくPryを起動させることができます。それでなにが変わるかというと例えば削除するときにエラーが発生したとします。
そういった場合、原因がどのコードにあるのかをPryを使って確認することができます。binding.pryをコード内に記述すると、そこがブレイクポイントとなりrailsの処理を止めることができます。

すでにインストールされているgemの確認

ターミナルで

$ gem list

で確認できます。

Gemfileでの記述

Gemfileの中の一番下に

gem 'pry-rails'

と記述しターミナルで

$ bundle install

を実行すればgemに適応される。

バージョン指定したいとき

Gemfile内の記述でmysql2のバージョンを指定したいときは

gem 'mysql2', '>= 0.4.4', '< 0.6.0'

と上記のように指定しておけば「mysql2は、0.4.4以上、0.6.0未満のバージョンを適用」となります。
バージョン指定したらターミナルで

$ bundle update

でバージョンを指定ができました。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?