LoginSignup
5

More than 5 years have passed since last update.

今使っているActiveRecordのバージョンを調べる方法

Posted at

とあるgemを作っている際、ActiveRecordのバージョンによって、deprecateになったメソッドを使わないようにする......といった要望が出てきて、ちらっと調査していたのですが、日本語の情報がなかなか出てこなかったので、こちらにメモしておきます。

irb
irb(main):001:0> require "active_record"
=> true
irb(main):002:0> ActiveRecord.version
=> #<Gem::Version "5.1.2">
irb(main):003:0> ActiveRecord::VERSION::STRING
=> "5.1.2"

APIdock - version (ActiveRecord)
https://apidock.com/rails/ActiveRecord/version/class

APIdock - ActiveRecord::VERSION
https://apidock.com/rails/ActiveRecord/VERSION

以上。
なお、Gem::Versionクラスを使ったバージョン比較については、こちらの記事で親切に解説されているので、一緒にどうぞ。

WEB SALAD - RubyとRailsで特定のバージョン下でのみ適用したいパッチを書く方法
http://web-salad.hateblo.jp/entry/2015/05/27/090000

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
5